diff options
Diffstat (limited to 'src')
113 files changed, 8188 insertions, 2217 deletions
diff --git a/src/android/app/build.gradle.kts b/src/android/app/build.gradle.kts index 5721327e7..f763c657e 100644 --- a/src/android/app/build.gradle.kts +++ b/src/android/app/build.gradle.kts | |||
| @@ -174,7 +174,8 @@ android { | |||
| 174 | "-DANDROID_ARM_NEON=true", // cryptopp requires Neon to work | 174 | "-DANDROID_ARM_NEON=true", // cryptopp requires Neon to work |
| 175 | "-DYUZU_USE_BUNDLED_VCPKG=ON", | 175 | "-DYUZU_USE_BUNDLED_VCPKG=ON", |
| 176 | "-DYUZU_USE_BUNDLED_FFMPEG=ON", | 176 | "-DYUZU_USE_BUNDLED_FFMPEG=ON", |
| 177 | "-DYUZU_ENABLE_LTO=ON" | 177 | "-DYUZU_ENABLE_LTO=ON", |
| 178 | "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" | ||
| 178 | ) | 179 | ) |
| 179 | 180 | ||
| 180 | abiFilters("arm64-v8a", "x86_64") | 181 | abiFilters("arm64-v8a", "x86_64") |
diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index 3d795b57f..e5d3158c8 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp | |||
| @@ -291,9 +291,6 @@ Core::SystemResultStatus EmulationSession::InitializeEmulation(const std::string | |||
| 291 | // Initialize filesystem. | 291 | // Initialize filesystem. |
| 292 | ConfigureFilesystemProvider(filepath); | 292 | ConfigureFilesystemProvider(filepath); |
| 293 | 293 | ||
| 294 | // Initialize account manager | ||
| 295 | m_profile_manager = std::make_unique<Service::Account::ProfileManager>(); | ||
| 296 | |||
| 297 | // Load the ROM. | 294 | // Load the ROM. |
| 298 | m_load_result = m_system.Load(EmulationSession::GetInstance().Window(), filepath); | 295 | m_load_result = m_system.Load(EmulationSession::GetInstance().Window(), filepath); |
| 299 | if (m_load_result != Core::SystemResultStatus::Success) { | 296 | if (m_load_result != Core::SystemResultStatus::Success) { |
| @@ -736,8 +733,8 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_initializeEmptyUserDirectory(JNIEnv* | |||
| 736 | auto vfs_nand_dir = EmulationSession::GetInstance().System().GetFilesystem()->OpenDirectory( | 733 | auto vfs_nand_dir = EmulationSession::GetInstance().System().GetFilesystem()->OpenDirectory( |
| 737 | Common::FS::PathToUTF8String(nand_dir), FileSys::Mode::Read); | 734 | Common::FS::PathToUTF8String(nand_dir), FileSys::Mode::Read); |
| 738 | 735 | ||
| 739 | Service::Account::ProfileManager manager; | 736 | const auto user_id = EmulationSession::GetInstance().System().GetProfileManager().GetUser( |
| 740 | const auto user_id = manager.GetUser(static_cast<std::size_t>(0)); | 737 | static_cast<std::size_t>(0)); |
| 741 | ASSERT(user_id); | 738 | ASSERT(user_id); |
| 742 | 739 | ||
| 743 | const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath( | 740 | const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath( |
diff --git a/src/android/app/src/main/jni/native.h b/src/android/app/src/main/jni/native.h index 78ef96802..f1457bd1f 100644 --- a/src/android/app/src/main/jni/native.h +++ b/src/android/app/src/main/jni/native.h | |||
| @@ -73,7 +73,6 @@ private: | |||
| 73 | std::atomic<bool> m_is_running = false; | 73 | std::atomic<bool> m_is_running = false; |
| 74 | std::atomic<bool> m_is_paused = false; | 74 | std::atomic<bool> m_is_paused = false; |
| 75 | SoftwareKeyboard::AndroidKeyboard* m_software_keyboard{}; | 75 | SoftwareKeyboard::AndroidKeyboard* m_software_keyboard{}; |
| 76 | std::unique_ptr<Service::Account::ProfileManager> m_profile_manager; | ||
| 77 | std::unique_ptr<FileSys::ManualContentProvider> m_manual_provider; | 76 | std::unique_ptr<FileSys::ManualContentProvider> m_manual_provider; |
| 78 | 77 | ||
| 79 | // GPU driver parameters | 78 | // GPU driver parameters |
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index 47d028d48..ba3081efb 100644 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h | |||
| @@ -123,6 +123,12 @@ namespace Common { | |||
| 123 | return u32(a) | u32(b) << 8 | u32(c) << 16 | u32(d) << 24; | 123 | return u32(a) | u32(b) << 8 | u32(c) << 16 | u32(d) << 24; |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | [[nodiscard]] constexpr u64 MakeMagic(char a, char b, char c, char d, char e, char f, char g, | ||
| 127 | char h) { | ||
| 128 | return u64(a) << 0 | u64(b) << 8 | u64(c) << 16 | u64(d) << 24 | u64(e) << 32 | u64(f) << 40 | | ||
| 129 | u64(g) << 48 | u64(h) << 56; | ||
| 130 | } | ||
| 131 | |||
| 126 | // std::size() does not support zero-size C arrays. We're fixing that. | 132 | // std::size() does not support zero-size C arrays. We're fixing that. |
| 127 | template <class C> | 133 | template <class C> |
| 128 | constexpr auto Size(const C& c) -> decltype(c.size()) { | 134 | constexpr auto Size(const C& c) -> decltype(c.size()) { |
diff --git a/src/common/fs/path_util.cpp b/src/common/fs/path_util.cpp index c3a81f9a9..d2f50432a 100644 --- a/src/common/fs/path_util.cpp +++ b/src/common/fs/path_util.cpp | |||
| @@ -354,18 +354,36 @@ std::string_view RemoveTrailingSlash(std::string_view path) { | |||
| 354 | return path; | 354 | return path; |
| 355 | } | 355 | } |
| 356 | 356 | ||
| 357 | std::vector<std::string> SplitPathComponents(std::string_view filename) { | 357 | template <typename F> |
| 358 | std::string copy(filename); | 358 | static void ForEachPathComponent(std::string_view filename, F&& cb) { |
| 359 | std::replace(copy.begin(), copy.end(), '\\', '/'); | 359 | const char* component_begin = filename.data(); |
| 360 | std::vector<std::string> out; | 360 | const char* const end = component_begin + filename.size(); |
| 361 | 361 | for (const char* it = component_begin; it != end; ++it) { | |
| 362 | std::stringstream stream(copy); | 362 | const char c = *it; |
| 363 | std::string item; | 363 | if (c == '\\' || c == '/') { |
| 364 | while (std::getline(stream, item, '/')) { | 364 | if (component_begin != it) { |
| 365 | out.push_back(std::move(item)); | 365 | cb(std::string_view{component_begin, it}); |
| 366 | } | ||
| 367 | component_begin = it + 1; | ||
| 368 | } | ||
| 366 | } | 369 | } |
| 370 | if (component_begin != end) { | ||
| 371 | cb(std::string_view{component_begin, end}); | ||
| 372 | } | ||
| 373 | } | ||
| 374 | |||
| 375 | std::vector<std::string_view> SplitPathComponents(std::string_view filename) { | ||
| 376 | std::vector<std::string_view> components; | ||
| 377 | ForEachPathComponent(filename, [&](auto component) { components.emplace_back(component); }); | ||
| 378 | |||
| 379 | return components; | ||
| 380 | } | ||
| 381 | |||
| 382 | std::vector<std::string> SplitPathComponentsCopy(std::string_view filename) { | ||
| 383 | std::vector<std::string> components; | ||
| 384 | ForEachPathComponent(filename, [&](auto component) { components.emplace_back(component); }); | ||
| 367 | 385 | ||
| 368 | return out; | 386 | return components; |
| 369 | } | 387 | } |
| 370 | 388 | ||
| 371 | std::string SanitizePath(std::string_view path_, DirectorySeparator directory_separator) { | 389 | std::string SanitizePath(std::string_view path_, DirectorySeparator directory_separator) { |
diff --git a/src/common/fs/path_util.h b/src/common/fs/path_util.h index 2874ea738..23c8b1359 100644 --- a/src/common/fs/path_util.h +++ b/src/common/fs/path_util.h | |||
| @@ -289,7 +289,11 @@ enum class DirectorySeparator { | |||
| 289 | 289 | ||
| 290 | // Splits the path on '/' or '\' and put the components into a vector | 290 | // Splits the path on '/' or '\' and put the components into a vector |
| 291 | // i.e. "C:\Users\Yuzu\Documents\save.bin" becomes {"C:", "Users", "Yuzu", "Documents", "save.bin" } | 291 | // i.e. "C:\Users\Yuzu\Documents\save.bin" becomes {"C:", "Users", "Yuzu", "Documents", "save.bin" } |
| 292 | [[nodiscard]] std::vector<std::string> SplitPathComponents(std::string_view filename); | 292 | [[nodiscard]] std::vector<std::string_view> SplitPathComponents(std::string_view filename); |
| 293 | |||
| 294 | // Splits the path on '/' or '\' and put the components into a vector | ||
| 295 | // i.e. "C:\Users\Yuzu\Documents\save.bin" becomes {"C:", "Users", "Yuzu", "Documents", "save.bin" } | ||
| 296 | [[nodiscard]] std::vector<std::string> SplitPathComponentsCopy(std::string_view filename); | ||
| 293 | 297 | ||
| 294 | // Removes trailing slash, makes all '\\' into '/', and removes duplicate '/'. Makes '/' into '\\' | 298 | // Removes trailing slash, makes all '\\' into '/', and removes duplicate '/'. Makes '/' into '\\' |
| 295 | // depending if directory_separator is BackwardSlash or PlatformDefault and running on windows | 299 | // depending if directory_separator is BackwardSlash or PlatformDefault and running on windows |
diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index 4bfc64f2d..e540375b8 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp | |||
| @@ -11,10 +11,6 @@ | |||
| 11 | 11 | ||
| 12 | #elif defined(__linux__) || defined(__FreeBSD__) // ^^^ Windows ^^^ vvv Linux vvv | 12 | #elif defined(__linux__) || defined(__FreeBSD__) // ^^^ Windows ^^^ vvv Linux vvv |
| 13 | 13 | ||
| 14 | #ifdef ANDROID | ||
| 15 | #include <android/sharedmem.h> | ||
| 16 | #endif | ||
| 17 | |||
| 18 | #ifndef _GNU_SOURCE | 14 | #ifndef _GNU_SOURCE |
| 19 | #define _GNU_SOURCE | 15 | #define _GNU_SOURCE |
| 20 | #endif | 16 | #endif |
| @@ -193,6 +189,11 @@ public: | |||
| 193 | } | 189 | } |
| 194 | } | 190 | } |
| 195 | 191 | ||
| 192 | bool ClearBackingRegion(size_t physical_offset, size_t length) { | ||
| 193 | // TODO: This does not seem to be possible on Windows. | ||
| 194 | return false; | ||
| 195 | } | ||
| 196 | |||
| 196 | void EnableDirectMappedAddress() { | 197 | void EnableDirectMappedAddress() { |
| 197 | // TODO | 198 | // TODO |
| 198 | UNREACHABLE(); | 199 | UNREACHABLE(); |
| @@ -442,9 +443,7 @@ public: | |||
| 442 | } | 443 | } |
| 443 | 444 | ||
| 444 | // Backing memory initialization | 445 | // Backing memory initialization |
| 445 | #ifdef ANDROID | 446 | #if defined(__FreeBSD__) && __FreeBSD__ < 13 |
| 446 | fd = ASharedMemory_create("HostMemory", backing_size); | ||
| 447 | #elif defined(__FreeBSD__) && __FreeBSD__ < 13 | ||
| 448 | // XXX Drop after FreeBSD 12.* reaches EOL on 2024-06-30 | 447 | // XXX Drop after FreeBSD 12.* reaches EOL on 2024-06-30 |
| 449 | fd = shm_open(SHM_ANON, O_RDWR, 0600); | 448 | fd = shm_open(SHM_ANON, O_RDWR, 0600); |
| 450 | #else | 449 | #else |
| @@ -455,7 +454,6 @@ public: | |||
| 455 | throw std::bad_alloc{}; | 454 | throw std::bad_alloc{}; |
| 456 | } | 455 | } |
| 457 | 456 | ||
| 458 | #ifndef ANDROID | ||
| 459 | // Defined to extend the file with zeros | 457 | // Defined to extend the file with zeros |
| 460 | int ret = ftruncate(fd, backing_size); | 458 | int ret = ftruncate(fd, backing_size); |
| 461 | if (ret != 0) { | 459 | if (ret != 0) { |
| @@ -463,7 +461,6 @@ public: | |||
| 463 | strerror(errno)); | 461 | strerror(errno)); |
| 464 | throw std::bad_alloc{}; | 462 | throw std::bad_alloc{}; |
| 465 | } | 463 | } |
| 466 | #endif | ||
| 467 | 464 | ||
| 468 | backing_base = static_cast<u8*>( | 465 | backing_base = static_cast<u8*>( |
| 469 | mmap(nullptr, backing_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)); | 466 | mmap(nullptr, backing_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)); |
| @@ -552,6 +549,19 @@ public: | |||
| 552 | ASSERT_MSG(ret == 0, "mprotect failed: {}", strerror(errno)); | 549 | ASSERT_MSG(ret == 0, "mprotect failed: {}", strerror(errno)); |
| 553 | } | 550 | } |
| 554 | 551 | ||
| 552 | bool ClearBackingRegion(size_t physical_offset, size_t length) { | ||
| 553 | #ifdef __linux__ | ||
| 554 | // Set MADV_REMOVE on backing map to destroy it instantly. | ||
| 555 | // This also deletes the area from the backing file. | ||
| 556 | int ret = madvise(backing_base + physical_offset, length, MADV_REMOVE); | ||
| 557 | ASSERT_MSG(ret == 0, "madvise failed: {}", strerror(errno)); | ||
| 558 | |||
| 559 | return true; | ||
| 560 | #else | ||
| 561 | return false; | ||
| 562 | #endif | ||
| 563 | } | ||
| 564 | |||
| 555 | void EnableDirectMappedAddress() { | 565 | void EnableDirectMappedAddress() { |
| 556 | virtual_base = nullptr; | 566 | virtual_base = nullptr; |
| 557 | } | 567 | } |
| @@ -623,6 +633,10 @@ public: | |||
| 623 | 633 | ||
| 624 | void Protect(size_t virtual_offset, size_t length, bool read, bool write, bool execute) {} | 634 | void Protect(size_t virtual_offset, size_t length, bool read, bool write, bool execute) {} |
| 625 | 635 | ||
| 636 | bool ClearBackingRegion(size_t physical_offset, size_t length) { | ||
| 637 | return false; | ||
| 638 | } | ||
| 639 | |||
| 626 | void EnableDirectMappedAddress() {} | 640 | void EnableDirectMappedAddress() {} |
| 627 | 641 | ||
| 628 | u8* backing_base{nullptr}; | 642 | u8* backing_base{nullptr}; |
| @@ -698,6 +712,12 @@ void HostMemory::Protect(size_t virtual_offset, size_t length, bool read, bool w | |||
| 698 | impl->Protect(virtual_offset + virtual_base_offset, length, read, write, execute); | 712 | impl->Protect(virtual_offset + virtual_base_offset, length, read, write, execute); |
| 699 | } | 713 | } |
| 700 | 714 | ||
| 715 | void HostMemory::ClearBackingRegion(size_t physical_offset, size_t length, u32 fill_value) { | ||
| 716 | if (!impl || fill_value != 0 || !impl->ClearBackingRegion(physical_offset, length)) { | ||
| 717 | std::memset(backing_base + physical_offset, fill_value, length); | ||
| 718 | } | ||
| 719 | } | ||
| 720 | |||
| 701 | void HostMemory::EnableDirectMappedAddress() { | 721 | void HostMemory::EnableDirectMappedAddress() { |
| 702 | if (impl) { | 722 | if (impl) { |
| 703 | impl->EnableDirectMappedAddress(); | 723 | impl->EnableDirectMappedAddress(); |
diff --git a/src/common/host_memory.h b/src/common/host_memory.h index cebfacab2..747c5850c 100644 --- a/src/common/host_memory.h +++ b/src/common/host_memory.h | |||
| @@ -48,6 +48,8 @@ public: | |||
| 48 | 48 | ||
| 49 | void EnableDirectMappedAddress(); | 49 | void EnableDirectMappedAddress(); |
| 50 | 50 | ||
| 51 | void ClearBackingRegion(size_t physical_offset, size_t length, u32 fill_value); | ||
| 52 | |||
| 51 | [[nodiscard]] u8* BackingBasePointer() noexcept { | 53 | [[nodiscard]] u8* BackingBasePointer() noexcept { |
| 52 | return backing_base; | 54 | return backing_base; |
| 53 | } | 55 | } |
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 27d636ed4..96ab39cb8 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -549,6 +549,11 @@ add_library(core STATIC | |||
| 549 | hle/service/hid/xcd.cpp | 549 | hle/service/hid/xcd.cpp |
| 550 | hle/service/hid/xcd.h | 550 | hle/service/hid/xcd.h |
| 551 | hle/service/hid/errors.h | 551 | hle/service/hid/errors.h |
| 552 | hle/service/hid/controllers/types/debug_pad_types.h | ||
| 553 | hle/service/hid/controllers/types/keyboard_types.h | ||
| 554 | hle/service/hid/controllers/types/mouse_types.h | ||
| 555 | hle/service/hid/controllers/types/npad_types.h | ||
| 556 | hle/service/hid/controllers/types/touch_types.h | ||
| 552 | hle/service/hid/controllers/applet_resource.cpp | 557 | hle/service/hid/controllers/applet_resource.cpp |
| 553 | hle/service/hid/controllers/applet_resource.h | 558 | hle/service/hid/controllers/applet_resource.h |
| 554 | hle/service/hid/controllers/console_six_axis.cpp | 559 | hle/service/hid/controllers/console_six_axis.cpp |
| @@ -569,14 +574,15 @@ add_library(core STATIC | |||
| 569 | hle/service/hid/controllers/palma.h | 574 | hle/service/hid/controllers/palma.h |
| 570 | hle/service/hid/controllers/seven_six_axis.cpp | 575 | hle/service/hid/controllers/seven_six_axis.cpp |
| 571 | hle/service/hid/controllers/seven_six_axis.h | 576 | hle/service/hid/controllers/seven_six_axis.h |
| 577 | hle/service/hid/controllers/shared_memory_format.h | ||
| 578 | hle/service/hid/controllers/shared_memory_holder.cpp | ||
| 579 | hle/service/hid/controllers/shared_memory_holder.h | ||
| 572 | hle/service/hid/controllers/six_axis.cpp | 580 | hle/service/hid/controllers/six_axis.cpp |
| 573 | hle/service/hid/controllers/six_axis.h | 581 | hle/service/hid/controllers/six_axis.h |
| 574 | hle/service/hid/controllers/stubbed.cpp | 582 | hle/service/hid/controllers/stubbed.cpp |
| 575 | hle/service/hid/controllers/stubbed.h | 583 | hle/service/hid/controllers/stubbed.h |
| 576 | hle/service/hid/controllers/touchscreen.cpp | 584 | hle/service/hid/controllers/touchscreen.cpp |
| 577 | hle/service/hid/controllers/touchscreen.h | 585 | hle/service/hid/controllers/touchscreen.h |
| 578 | hle/service/hid/controllers/xpad.cpp | ||
| 579 | hle/service/hid/controllers/xpad.h | ||
| 580 | hle/service/hid/hidbus/hidbus_base.cpp | 586 | hle/service/hid/hidbus/hidbus_base.cpp |
| 581 | hle/service/hid/hidbus/hidbus_base.h | 587 | hle/service/hid/hidbus/hidbus_base.h |
| 582 | hle/service/hid/hidbus/ringcon.cpp | 588 | hle/service/hid/hidbus/ringcon.cpp |
| @@ -772,12 +778,24 @@ add_library(core STATIC | |||
| 772 | hle/service/kernel_helpers.h | 778 | hle/service/kernel_helpers.h |
| 773 | hle/service/mutex.cpp | 779 | hle/service/mutex.cpp |
| 774 | hle/service/mutex.h | 780 | hle/service/mutex.h |
| 781 | hle/service/ro/ro_nro_utils.cpp | ||
| 782 | hle/service/ro/ro_nro_utils.h | ||
| 783 | hle/service/ro/ro_results.h | ||
| 784 | hle/service/ro/ro_types.h | ||
| 785 | hle/service/ro/ro.cpp | ||
| 786 | hle/service/ro/ro.h | ||
| 775 | hle/service/server_manager.cpp | 787 | hle/service/server_manager.cpp |
| 776 | hle/service/server_manager.h | 788 | hle/service/server_manager.h |
| 777 | hle/service/service.cpp | 789 | hle/service/service.cpp |
| 778 | hle/service/service.h | 790 | hle/service/service.h |
| 779 | hle/service/set/set.cpp | 791 | hle/service/set/set.cpp |
| 780 | hle/service/set/set.h | 792 | hle/service/set/set.h |
| 793 | hle/service/set/appln_settings.cpp | ||
| 794 | hle/service/set/appln_settings.h | ||
| 795 | hle/service/set/device_settings.cpp | ||
| 796 | hle/service/set/device_settings.h | ||
| 797 | hle/service/set/private_settings.cpp | ||
| 798 | hle/service/set/private_settings.h | ||
| 781 | hle/service/set/set_cal.cpp | 799 | hle/service/set/set_cal.cpp |
| 782 | hle/service/set/set_cal.h | 800 | hle/service/set/set_cal.h |
| 783 | hle/service/set/set_fd.cpp | 801 | hle/service/set/set_fd.cpp |
| @@ -786,6 +804,8 @@ add_library(core STATIC | |||
| 786 | hle/service/set/set_sys.h | 804 | hle/service/set/set_sys.h |
| 787 | hle/service/set/settings.cpp | 805 | hle/service/set/settings.cpp |
| 788 | hle/service/set/settings.h | 806 | hle/service/set/settings.h |
| 807 | hle/service/set/system_settings.cpp | ||
| 808 | hle/service/set/system_settings.h | ||
| 789 | hle/service/sm/sm.cpp | 809 | hle/service/sm/sm.cpp |
| 790 | hle/service/sm/sm.h | 810 | hle/service/sm/sm.h |
| 791 | hle/service/sm/sm_controller.cpp | 811 | hle/service/sm/sm_controller.cpp |
| @@ -941,15 +961,19 @@ if (HAS_NCE) | |||
| 941 | set(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp") | 961 | set(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp") |
| 942 | 962 | ||
| 943 | target_sources(core PRIVATE | 963 | target_sources(core PRIVATE |
| 964 | arm/nce/arm_nce_asm_definitions.h | ||
| 944 | arm/nce/arm_nce.cpp | 965 | arm/nce/arm_nce.cpp |
| 945 | arm/nce/arm_nce.h | 966 | arm/nce/arm_nce.h |
| 946 | arm/nce/arm_nce.s | 967 | arm/nce/arm_nce.s |
| 947 | arm/nce/guest_context.h | 968 | arm/nce/guest_context.h |
| 969 | arm/nce/instructions.h | ||
| 970 | arm/nce/interpreter_visitor.cpp | ||
| 971 | arm/nce/interpreter_visitor.h | ||
| 948 | arm/nce/patcher.cpp | 972 | arm/nce/patcher.cpp |
| 949 | arm/nce/patcher.h | 973 | arm/nce/patcher.h |
| 950 | arm/nce/instructions.h | 974 | arm/nce/visitor_base.h |
| 951 | ) | 975 | ) |
| 952 | target_link_libraries(core PRIVATE merry::oaknut) | 976 | target_link_libraries(core PRIVATE merry::mcl merry::oaknut) |
| 953 | endif() | 977 | endif() |
| 954 | 978 | ||
| 955 | if (ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64) | 979 | if (ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64) |
diff --git a/src/core/arm/nce/arm_nce.cpp b/src/core/arm/nce/arm_nce.cpp index b42a32a0b..1311e66a9 100644 --- a/src/core/arm/nce/arm_nce.cpp +++ b/src/core/arm/nce/arm_nce.cpp | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include "common/signal_chain.h" | 7 | #include "common/signal_chain.h" |
| 8 | #include "core/arm/nce/arm_nce.h" | 8 | #include "core/arm/nce/arm_nce.h" |
| 9 | #include "core/arm/nce/guest_context.h" | 9 | #include "core/arm/nce/interpreter_visitor.h" |
| 10 | #include "core/arm/nce/patcher.h" | 10 | #include "core/arm/nce/patcher.h" |
| 11 | #include "core/core.h" | 11 | #include "core/core.h" |
| 12 | #include "core/memory.h" | 12 | #include "core/memory.h" |
| @@ -21,7 +21,8 @@ namespace Core { | |||
| 21 | 21 | ||
| 22 | namespace { | 22 | namespace { |
| 23 | 23 | ||
| 24 | struct sigaction g_orig_action; | 24 | struct sigaction g_orig_bus_action; |
| 25 | struct sigaction g_orig_segv_action; | ||
| 25 | 26 | ||
| 26 | // Verify assembly offsets. | 27 | // Verify assembly offsets. |
| 27 | using NativeExecutionParameters = Kernel::KThread::NativeExecutionParameters; | 28 | using NativeExecutionParameters = Kernel::KThread::NativeExecutionParameters; |
| @@ -37,6 +38,9 @@ fpsimd_context* GetFloatingPointState(mcontext_t& host_ctx) { | |||
| 37 | return reinterpret_cast<fpsimd_context*>(header); | 38 | return reinterpret_cast<fpsimd_context*>(header); |
| 38 | } | 39 | } |
| 39 | 40 | ||
| 41 | using namespace Common::Literals; | ||
| 42 | constexpr u32 StackSize = 32_KiB; | ||
| 43 | |||
| 40 | } // namespace | 44 | } // namespace |
| 41 | 45 | ||
| 42 | void* ArmNce::RestoreGuestContext(void* raw_context) { | 46 | void* ArmNce::RestoreGuestContext(void* raw_context) { |
| @@ -104,19 +108,10 @@ void ArmNce::SaveGuestContext(GuestContext* guest_ctx, void* raw_context) { | |||
| 104 | host_ctx.regs[0] = guest_ctx->esr_el1.exchange(0); | 108 | host_ctx.regs[0] = guest_ctx->esr_el1.exchange(0); |
| 105 | } | 109 | } |
| 106 | 110 | ||
| 107 | bool ArmNce::HandleGuestFault(GuestContext* guest_ctx, void* raw_info, void* raw_context) { | 111 | bool ArmNce::HandleFailedGuestFault(GuestContext* guest_ctx, void* raw_info, void* raw_context) { |
| 108 | auto& host_ctx = static_cast<ucontext_t*>(raw_context)->uc_mcontext; | 112 | auto& host_ctx = static_cast<ucontext_t*>(raw_context)->uc_mcontext; |
| 109 | auto* info = static_cast<siginfo_t*>(raw_info); | 113 | auto* info = static_cast<siginfo_t*>(raw_info); |
| 110 | 114 | ||
| 111 | // Try to handle an invalid access. | ||
| 112 | // TODO: handle accesses which split a page? | ||
| 113 | const Common::ProcessAddress addr = | ||
| 114 | (reinterpret_cast<u64>(info->si_addr) & ~Memory::YUZU_PAGEMASK); | ||
| 115 | if (guest_ctx->system->ApplicationMemory().InvalidateNCE(addr, Memory::YUZU_PAGESIZE)) { | ||
| 116 | // We handled the access successfully and are returning to guest code. | ||
| 117 | return true; | ||
| 118 | } | ||
| 119 | |||
| 120 | // We can't handle the access, so determine why we crashed. | 115 | // We can't handle the access, so determine why we crashed. |
| 121 | const bool is_prefetch_abort = host_ctx.pc == reinterpret_cast<u64>(info->si_addr); | 116 | const bool is_prefetch_abort = host_ctx.pc == reinterpret_cast<u64>(info->si_addr); |
| 122 | 117 | ||
| @@ -143,8 +138,44 @@ bool ArmNce::HandleGuestFault(GuestContext* guest_ctx, void* raw_info, void* raw | |||
| 143 | return false; | 138 | return false; |
| 144 | } | 139 | } |
| 145 | 140 | ||
| 146 | void ArmNce::HandleHostFault(int sig, void* raw_info, void* raw_context) { | 141 | bool ArmNce::HandleGuestAlignmentFault(GuestContext* guest_ctx, void* raw_info, void* raw_context) { |
| 147 | return g_orig_action.sa_sigaction(sig, static_cast<siginfo_t*>(raw_info), raw_context); | 142 | auto& host_ctx = static_cast<ucontext_t*>(raw_context)->uc_mcontext; |
| 143 | auto* fpctx = GetFloatingPointState(host_ctx); | ||
| 144 | auto& memory = guest_ctx->system->ApplicationMemory(); | ||
| 145 | |||
| 146 | // Match and execute an instruction. | ||
| 147 | auto next_pc = MatchAndExecuteOneInstruction(memory, &host_ctx, fpctx); | ||
| 148 | if (next_pc) { | ||
| 149 | host_ctx.pc = *next_pc; | ||
| 150 | return true; | ||
| 151 | } | ||
| 152 | |||
| 153 | // We couldn't handle the access. | ||
| 154 | return HandleFailedGuestFault(guest_ctx, raw_info, raw_context); | ||
| 155 | } | ||
| 156 | |||
| 157 | bool ArmNce::HandleGuestAccessFault(GuestContext* guest_ctx, void* raw_info, void* raw_context) { | ||
| 158 | auto* info = static_cast<siginfo_t*>(raw_info); | ||
| 159 | |||
| 160 | // Try to handle an invalid access. | ||
| 161 | // TODO: handle accesses which split a page? | ||
| 162 | const Common::ProcessAddress addr = | ||
| 163 | (reinterpret_cast<u64>(info->si_addr) & ~Memory::YUZU_PAGEMASK); | ||
| 164 | if (guest_ctx->system->ApplicationMemory().InvalidateNCE(addr, Memory::YUZU_PAGESIZE)) { | ||
| 165 | // We handled the access successfully and are returning to guest code. | ||
| 166 | return true; | ||
| 167 | } | ||
| 168 | |||
| 169 | // We couldn't handle the access. | ||
| 170 | return HandleFailedGuestFault(guest_ctx, raw_info, raw_context); | ||
| 171 | } | ||
| 172 | |||
| 173 | void ArmNce::HandleHostAlignmentFault(int sig, void* raw_info, void* raw_context) { | ||
| 174 | return g_orig_bus_action.sa_sigaction(sig, static_cast<siginfo_t*>(raw_info), raw_context); | ||
| 175 | } | ||
| 176 | |||
| 177 | void ArmNce::HandleHostAccessFault(int sig, void* raw_info, void* raw_context) { | ||
| 178 | return g_orig_segv_action.sa_sigaction(sig, static_cast<siginfo_t*>(raw_info), raw_context); | ||
| 148 | } | 179 | } |
| 149 | 180 | ||
| 150 | void ArmNce::LockThread(Kernel::KThread* thread) { | 181 | void ArmNce::LockThread(Kernel::KThread* thread) { |
| @@ -225,18 +256,31 @@ ArmNce::ArmNce(System& system, bool uses_wall_clock, std::size_t core_index) | |||
| 225 | ArmNce::~ArmNce() = default; | 256 | ArmNce::~ArmNce() = default; |
| 226 | 257 | ||
| 227 | void ArmNce::Initialize() { | 258 | void ArmNce::Initialize() { |
| 228 | m_thread_id = gettid(); | 259 | if (m_thread_id == -1) { |
| 260 | m_thread_id = gettid(); | ||
| 261 | } | ||
| 262 | |||
| 263 | // Configure signal stack. | ||
| 264 | if (!m_stack) { | ||
| 265 | m_stack = std::make_unique<u8[]>(StackSize); | ||
| 266 | |||
| 267 | stack_t ss{}; | ||
| 268 | ss.ss_sp = m_stack.get(); | ||
| 269 | ss.ss_size = StackSize; | ||
| 270 | sigaltstack(&ss, nullptr); | ||
| 271 | } | ||
| 229 | 272 | ||
| 230 | // Setup our signals | 273 | // Set up signals. |
| 231 | static std::once_flag signals; | 274 | static std::once_flag flag; |
| 232 | std::call_once(signals, [] { | 275 | std::call_once(flag, [] { |
| 233 | using HandlerType = decltype(sigaction::sa_sigaction); | 276 | using HandlerType = decltype(sigaction::sa_sigaction); |
| 234 | 277 | ||
| 235 | sigset_t signal_mask; | 278 | sigset_t signal_mask; |
| 236 | sigemptyset(&signal_mask); | 279 | sigemptyset(&signal_mask); |
| 237 | sigaddset(&signal_mask, ReturnToRunCodeByExceptionLevelChangeSignal); | 280 | sigaddset(&signal_mask, ReturnToRunCodeByExceptionLevelChangeSignal); |
| 238 | sigaddset(&signal_mask, BreakFromRunCodeSignal); | 281 | sigaddset(&signal_mask, BreakFromRunCodeSignal); |
| 239 | sigaddset(&signal_mask, GuestFaultSignal); | 282 | sigaddset(&signal_mask, GuestAlignmentFaultSignal); |
| 283 | sigaddset(&signal_mask, GuestAccessFaultSignal); | ||
| 240 | 284 | ||
| 241 | struct sigaction return_to_run_code_action {}; | 285 | struct sigaction return_to_run_code_action {}; |
| 242 | return_to_run_code_action.sa_flags = SA_SIGINFO | SA_ONSTACK; | 286 | return_to_run_code_action.sa_flags = SA_SIGINFO | SA_ONSTACK; |
| @@ -253,18 +297,19 @@ void ArmNce::Initialize() { | |||
| 253 | break_from_run_code_action.sa_mask = signal_mask; | 297 | break_from_run_code_action.sa_mask = signal_mask; |
| 254 | Common::SigAction(BreakFromRunCodeSignal, &break_from_run_code_action, nullptr); | 298 | Common::SigAction(BreakFromRunCodeSignal, &break_from_run_code_action, nullptr); |
| 255 | 299 | ||
| 256 | struct sigaction fault_action {}; | 300 | struct sigaction alignment_fault_action {}; |
| 257 | fault_action.sa_flags = SA_SIGINFO | SA_ONSTACK | SA_RESTART; | 301 | alignment_fault_action.sa_flags = SA_SIGINFO | SA_ONSTACK; |
| 258 | fault_action.sa_sigaction = reinterpret_cast<HandlerType>(&ArmNce::GuestFaultSignalHandler); | 302 | alignment_fault_action.sa_sigaction = |
| 259 | fault_action.sa_mask = signal_mask; | 303 | reinterpret_cast<HandlerType>(&ArmNce::GuestAlignmentFaultSignalHandler); |
| 260 | Common::SigAction(GuestFaultSignal, &fault_action, &g_orig_action); | 304 | alignment_fault_action.sa_mask = signal_mask; |
| 261 | 305 | Common::SigAction(GuestAlignmentFaultSignal, &alignment_fault_action, nullptr); | |
| 262 | // Simplify call for g_orig_action. | 306 | |
| 263 | // These fields occupy the same space in memory, so this should be a no-op in practice. | 307 | struct sigaction access_fault_action {}; |
| 264 | if (!(g_orig_action.sa_flags & SA_SIGINFO)) { | 308 | access_fault_action.sa_flags = SA_SIGINFO | SA_ONSTACK | SA_RESTART; |
| 265 | g_orig_action.sa_sigaction = | 309 | access_fault_action.sa_sigaction = |
| 266 | reinterpret_cast<decltype(g_orig_action.sa_sigaction)>(g_orig_action.sa_handler); | 310 | reinterpret_cast<HandlerType>(&ArmNce::GuestAccessFaultSignalHandler); |
| 267 | } | 311 | access_fault_action.sa_mask = signal_mask; |
| 312 | Common::SigAction(GuestAccessFaultSignal, &access_fault_action, &g_orig_segv_action); | ||
| 268 | }); | 313 | }); |
| 269 | } | 314 | } |
| 270 | 315 | ||
diff --git a/src/core/arm/nce/arm_nce.h b/src/core/arm/nce/arm_nce.h index f55c10d1d..be9b304c4 100644 --- a/src/core/arm/nce/arm_nce.h +++ b/src/core/arm/nce/arm_nce.h | |||
| @@ -61,7 +61,8 @@ private: | |||
| 61 | static void ReturnToRunCodeByExceptionLevelChangeSignalHandler(int sig, void* info, | 61 | static void ReturnToRunCodeByExceptionLevelChangeSignalHandler(int sig, void* info, |
| 62 | void* raw_context); | 62 | void* raw_context); |
| 63 | static void BreakFromRunCodeSignalHandler(int sig, void* info, void* raw_context); | 63 | static void BreakFromRunCodeSignalHandler(int sig, void* info, void* raw_context); |
| 64 | static void GuestFaultSignalHandler(int sig, void* info, void* raw_context); | 64 | static void GuestAlignmentFaultSignalHandler(int sig, void* info, void* raw_context); |
| 65 | static void GuestAccessFaultSignalHandler(int sig, void* info, void* raw_context); | ||
| 65 | 66 | ||
| 66 | static void LockThreadParameters(void* tpidr); | 67 | static void LockThreadParameters(void* tpidr); |
| 67 | static void UnlockThreadParameters(void* tpidr); | 68 | static void UnlockThreadParameters(void* tpidr); |
| @@ -70,8 +71,11 @@ private: | |||
| 70 | // C++ implementation functions for assembly definitions. | 71 | // C++ implementation functions for assembly definitions. |
| 71 | static void* RestoreGuestContext(void* raw_context); | 72 | static void* RestoreGuestContext(void* raw_context); |
| 72 | static void SaveGuestContext(GuestContext* ctx, void* raw_context); | 73 | static void SaveGuestContext(GuestContext* ctx, void* raw_context); |
| 73 | static bool HandleGuestFault(GuestContext* ctx, void* info, void* raw_context); | 74 | static bool HandleFailedGuestFault(GuestContext* ctx, void* info, void* raw_context); |
| 74 | static void HandleHostFault(int sig, void* info, void* raw_context); | 75 | static bool HandleGuestAlignmentFault(GuestContext* ctx, void* info, void* raw_context); |
| 76 | static bool HandleGuestAccessFault(GuestContext* ctx, void* info, void* raw_context); | ||
| 77 | static void HandleHostAlignmentFault(int sig, void* info, void* raw_context); | ||
| 78 | static void HandleHostAccessFault(int sig, void* info, void* raw_context); | ||
| 75 | 79 | ||
| 76 | public: | 80 | public: |
| 77 | Core::System& m_system; | 81 | Core::System& m_system; |
| @@ -83,6 +87,9 @@ public: | |||
| 83 | // Core context. | 87 | // Core context. |
| 84 | GuestContext m_guest_ctx{}; | 88 | GuestContext m_guest_ctx{}; |
| 85 | Kernel::KThread* m_running_thread{}; | 89 | Kernel::KThread* m_running_thread{}; |
| 90 | |||
| 91 | // Stack for signal processing. | ||
| 92 | std::unique_ptr<u8[]> m_stack{}; | ||
| 86 | }; | 93 | }; |
| 87 | 94 | ||
| 88 | } // namespace Core | 95 | } // namespace Core |
diff --git a/src/core/arm/nce/arm_nce.s b/src/core/arm/nce/arm_nce.s index 4aeda4740..c68c05949 100644 --- a/src/core/arm/nce/arm_nce.s +++ b/src/core/arm/nce/arm_nce.s | |||
| @@ -130,11 +130,11 @@ _ZN4Core6ArmNce29BreakFromRunCodeSignalHandlerEiPvS1_: | |||
| 130 | ret | 130 | ret |
| 131 | 131 | ||
| 132 | 132 | ||
| 133 | /* static void Core::ArmNce::GuestFaultSignalHandler(int sig, void* info, void* raw_context) */ | 133 | /* static void Core::ArmNce::GuestAlignmentFaultSignalHandler(int sig, void* info, void* raw_context) */ |
| 134 | .section .text._ZN4Core6ArmNce23GuestFaultSignalHandlerEiPvS1_, "ax", %progbits | 134 | .section .text._ZN4Core6ArmNce32GuestAlignmentFaultSignalHandlerEiPvS1_, "ax", %progbits |
| 135 | .global _ZN4Core6ArmNce23GuestFaultSignalHandlerEiPvS1_ | 135 | .global _ZN4Core6ArmNce32GuestAlignmentFaultSignalHandlerEiPvS1_ |
| 136 | .type _ZN4Core6ArmNce23GuestFaultSignalHandlerEiPvS1_, %function | 136 | .type _ZN4Core6ArmNce32GuestAlignmentFaultSignalHandlerEiPvS1_, %function |
| 137 | _ZN4Core6ArmNce23GuestFaultSignalHandlerEiPvS1_: | 137 | _ZN4Core6ArmNce32GuestAlignmentFaultSignalHandlerEiPvS1_: |
| 138 | /* Check to see if we have the correct TLS magic. */ | 138 | /* Check to see if we have the correct TLS magic. */ |
| 139 | mrs x8, tpidr_el0 | 139 | mrs x8, tpidr_el0 |
| 140 | ldr w9, [x8, #(TpidrEl0TlsMagic)] | 140 | ldr w9, [x8, #(TpidrEl0TlsMagic)] |
| @@ -146,7 +146,7 @@ _ZN4Core6ArmNce23GuestFaultSignalHandlerEiPvS1_: | |||
| 146 | 146 | ||
| 147 | /* Incorrect TLS magic, so this is a host fault. */ | 147 | /* Incorrect TLS magic, so this is a host fault. */ |
| 148 | /* Tail call the handler. */ | 148 | /* Tail call the handler. */ |
| 149 | b _ZN4Core6ArmNce15HandleHostFaultEiPvS1_ | 149 | b _ZN4Core6ArmNce24HandleHostAlignmentFaultEiPvS1_ |
| 150 | 150 | ||
| 151 | 1: | 151 | 1: |
| 152 | /* Correct TLS magic, so this is a guest fault. */ | 152 | /* Correct TLS magic, so this is a guest fault. */ |
| @@ -163,7 +163,53 @@ _ZN4Core6ArmNce23GuestFaultSignalHandlerEiPvS1_: | |||
| 163 | msr tpidr_el0, x3 | 163 | msr tpidr_el0, x3 |
| 164 | 164 | ||
| 165 | /* Call the handler. */ | 165 | /* Call the handler. */ |
| 166 | bl _ZN4Core6ArmNce16HandleGuestFaultEPNS_12GuestContextEPvS3_ | 166 | bl _ZN4Core6ArmNce25HandleGuestAlignmentFaultEPNS_12GuestContextEPvS3_ |
| 167 | |||
| 168 | /* If the handler returned false, we want to preserve the host tpidr_el0. */ | ||
| 169 | cbz x0, 2f | ||
| 170 | |||
| 171 | /* Otherwise, restore guest tpidr_el0. */ | ||
| 172 | msr tpidr_el0, x19 | ||
| 173 | |||
| 174 | 2: | ||
| 175 | ldr x19, [sp, #0x10] | ||
| 176 | ldp x29, x30, [sp], #0x20 | ||
| 177 | ret | ||
| 178 | |||
| 179 | /* static void Core::ArmNce::GuestAccessFaultSignalHandler(int sig, void* info, void* raw_context) */ | ||
| 180 | .section .text._ZN4Core6ArmNce29GuestAccessFaultSignalHandlerEiPvS1_, "ax", %progbits | ||
| 181 | .global _ZN4Core6ArmNce29GuestAccessFaultSignalHandlerEiPvS1_ | ||
| 182 | .type _ZN4Core6ArmNce29GuestAccessFaultSignalHandlerEiPvS1_, %function | ||
| 183 | _ZN4Core6ArmNce29GuestAccessFaultSignalHandlerEiPvS1_: | ||
| 184 | /* Check to see if we have the correct TLS magic. */ | ||
| 185 | mrs x8, tpidr_el0 | ||
| 186 | ldr w9, [x8, #(TpidrEl0TlsMagic)] | ||
| 187 | |||
| 188 | LOAD_IMMEDIATE_32(w10, TlsMagic) | ||
| 189 | |||
| 190 | cmp w9, w10 | ||
| 191 | b.eq 1f | ||
| 192 | |||
| 193 | /* Incorrect TLS magic, so this is a host fault. */ | ||
| 194 | /* Tail call the handler. */ | ||
| 195 | b _ZN4Core6ArmNce21HandleHostAccessFaultEiPvS1_ | ||
| 196 | |||
| 197 | 1: | ||
| 198 | /* Correct TLS magic, so this is a guest fault. */ | ||
| 199 | stp x29, x30, [sp, #-0x20]! | ||
| 200 | str x19, [sp, #0x10] | ||
| 201 | mov x29, sp | ||
| 202 | |||
| 203 | /* Save the old tpidr_el0. */ | ||
| 204 | mov x19, x8 | ||
| 205 | |||
| 206 | /* Restore host tpidr_el0. */ | ||
| 207 | ldr x0, [x8, #(TpidrEl0NativeContext)] | ||
| 208 | ldr x3, [x0, #(GuestContextHostContext + HostContextTpidrEl0)] | ||
| 209 | msr tpidr_el0, x3 | ||
| 210 | |||
| 211 | /* Call the handler. */ | ||
| 212 | bl _ZN4Core6ArmNce22HandleGuestAccessFaultEPNS_12GuestContextEPvS3_ | ||
| 167 | 213 | ||
| 168 | /* If the handler returned false, we want to preserve the host tpidr_el0. */ | 214 | /* If the handler returned false, we want to preserve the host tpidr_el0. */ |
| 169 | cbz x0, 2f | 215 | cbz x0, 2f |
diff --git a/src/core/arm/nce/arm_nce_asm_definitions.h b/src/core/arm/nce/arm_nce_asm_definitions.h index 8a9b285b5..8ea4383f7 100644 --- a/src/core/arm/nce/arm_nce_asm_definitions.h +++ b/src/core/arm/nce/arm_nce_asm_definitions.h | |||
| @@ -10,7 +10,8 @@ | |||
| 10 | 10 | ||
| 11 | #define ReturnToRunCodeByExceptionLevelChangeSignal SIGUSR2 | 11 | #define ReturnToRunCodeByExceptionLevelChangeSignal SIGUSR2 |
| 12 | #define BreakFromRunCodeSignal SIGURG | 12 | #define BreakFromRunCodeSignal SIGURG |
| 13 | #define GuestFaultSignal SIGSEGV | 13 | #define GuestAccessFaultSignal SIGSEGV |
| 14 | #define GuestAlignmentFaultSignal SIGBUS | ||
| 14 | 15 | ||
| 15 | #define GuestContextSp 0xF8 | 16 | #define GuestContextSp 0xF8 |
| 16 | #define GuestContextHostContext 0x320 | 17 | #define GuestContextHostContext 0x320 |
diff --git a/src/core/arm/nce/interpreter_visitor.cpp b/src/core/arm/nce/interpreter_visitor.cpp new file mode 100644 index 000000000..8e81c66a5 --- /dev/null +++ b/src/core/arm/nce/interpreter_visitor.cpp | |||
| @@ -0,0 +1,825 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-FileCopyrightText: Copyright 2023 merryhime <https://mary.rs> | ||
| 3 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 4 | |||
| 5 | #include "common/bit_cast.h" | ||
| 6 | #include "core/arm/nce/interpreter_visitor.h" | ||
| 7 | |||
| 8 | #include <dynarmic/frontend/A64/decoder/a64.h> | ||
| 9 | |||
| 10 | namespace Core { | ||
| 11 | |||
| 12 | template <u32 BitSize> | ||
| 13 | u64 SignExtendToLong(u64 value) { | ||
| 14 | u64 mask = 1ULL << (BitSize - 1); | ||
| 15 | value &= (1ULL << BitSize) - 1; | ||
| 16 | return (value ^ mask) - mask; | ||
| 17 | } | ||
| 18 | |||
| 19 | static u64 SignExtendToLong(u64 value, u64 bitsize) { | ||
| 20 | switch (bitsize) { | ||
| 21 | case 8: | ||
| 22 | return SignExtendToLong<8>(value); | ||
| 23 | case 16: | ||
| 24 | return SignExtendToLong<16>(value); | ||
| 25 | case 32: | ||
| 26 | return SignExtendToLong<32>(value); | ||
| 27 | default: | ||
| 28 | return value; | ||
| 29 | } | ||
| 30 | } | ||
| 31 | |||
| 32 | template <u64 BitSize> | ||
| 33 | u32 SignExtendToWord(u32 value) { | ||
| 34 | u32 mask = 1ULL << (BitSize - 1); | ||
| 35 | value &= (1ULL << BitSize) - 1; | ||
| 36 | return (value ^ mask) - mask; | ||
| 37 | } | ||
| 38 | |||
| 39 | static u32 SignExtendToWord(u32 value, u64 bitsize) { | ||
| 40 | switch (bitsize) { | ||
| 41 | case 8: | ||
| 42 | return SignExtendToWord<8>(value); | ||
| 43 | case 16: | ||
| 44 | return SignExtendToWord<16>(value); | ||
| 45 | default: | ||
| 46 | return value; | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | static u64 SignExtend(u64 value, u64 bitsize, u64 regsize) { | ||
| 51 | if (regsize == 64) { | ||
| 52 | return SignExtendToLong(value, bitsize); | ||
| 53 | } else { | ||
| 54 | return SignExtendToWord(static_cast<u32>(value), bitsize); | ||
| 55 | } | ||
| 56 | } | ||
| 57 | |||
| 58 | static u128 VectorGetElement(u128 value, u64 bitsize) { | ||
| 59 | switch (bitsize) { | ||
| 60 | case 8: | ||
| 61 | return {value[0] & ((1ULL << 8) - 1), 0}; | ||
| 62 | case 16: | ||
| 63 | return {value[0] & ((1ULL << 16) - 1), 0}; | ||
| 64 | case 32: | ||
| 65 | return {value[0] & ((1ULL << 32) - 1), 0}; | ||
| 66 | case 64: | ||
| 67 | return {value[0], 0}; | ||
| 68 | default: | ||
| 69 | return value; | ||
| 70 | } | ||
| 71 | } | ||
| 72 | |||
| 73 | u64 InterpreterVisitor::ExtendReg(size_t bitsize, Reg reg, Imm<3> option, u8 shift) { | ||
| 74 | ASSERT(shift <= 4); | ||
| 75 | ASSERT(bitsize == 32 || bitsize == 64); | ||
| 76 | u64 val = this->GetReg(reg); | ||
| 77 | size_t len; | ||
| 78 | u64 extended; | ||
| 79 | bool signed_extend; | ||
| 80 | |||
| 81 | switch (option.ZeroExtend()) { | ||
| 82 | case 0b000: { // UXTB | ||
| 83 | val &= ((1ULL << 8) - 1); | ||
| 84 | len = 8; | ||
| 85 | signed_extend = false; | ||
| 86 | break; | ||
| 87 | } | ||
| 88 | case 0b001: { // UXTH | ||
| 89 | val &= ((1ULL << 16) - 1); | ||
| 90 | len = 16; | ||
| 91 | signed_extend = false; | ||
| 92 | break; | ||
| 93 | } | ||
| 94 | case 0b010: { // UXTW | ||
| 95 | val &= ((1ULL << 32) - 1); | ||
| 96 | len = 32; | ||
| 97 | signed_extend = false; | ||
| 98 | break; | ||
| 99 | } | ||
| 100 | case 0b011: { // UXTX | ||
| 101 | len = 64; | ||
| 102 | signed_extend = false; | ||
| 103 | break; | ||
| 104 | } | ||
| 105 | case 0b100: { // SXTB | ||
| 106 | val &= ((1ULL << 8) - 1); | ||
| 107 | len = 8; | ||
| 108 | signed_extend = true; | ||
| 109 | break; | ||
| 110 | } | ||
| 111 | case 0b101: { // SXTH | ||
| 112 | val &= ((1ULL << 16) - 1); | ||
| 113 | len = 16; | ||
| 114 | signed_extend = true; | ||
| 115 | break; | ||
| 116 | } | ||
| 117 | case 0b110: { // SXTW | ||
| 118 | val &= ((1ULL << 32) - 1); | ||
| 119 | len = 32; | ||
| 120 | signed_extend = true; | ||
| 121 | break; | ||
| 122 | } | ||
| 123 | case 0b111: { // SXTX | ||
| 124 | len = 64; | ||
| 125 | signed_extend = true; | ||
| 126 | break; | ||
| 127 | } | ||
| 128 | default: | ||
| 129 | UNREACHABLE(); | ||
| 130 | } | ||
| 131 | |||
| 132 | if (len < bitsize && signed_extend) { | ||
| 133 | extended = SignExtend(val, len, bitsize); | ||
| 134 | } else { | ||
| 135 | extended = val; | ||
| 136 | } | ||
| 137 | |||
| 138 | return extended << shift; | ||
| 139 | } | ||
| 140 | |||
| 141 | u128 InterpreterVisitor::GetVec(Vec v) { | ||
| 142 | return m_fpsimd_regs[static_cast<u32>(v)]; | ||
| 143 | } | ||
| 144 | |||
| 145 | u64 InterpreterVisitor::GetReg(Reg r) { | ||
| 146 | return m_regs[static_cast<u32>(r)]; | ||
| 147 | } | ||
| 148 | |||
| 149 | u64 InterpreterVisitor::GetSp() { | ||
| 150 | return m_sp; | ||
| 151 | } | ||
| 152 | |||
| 153 | u64 InterpreterVisitor::GetPc() { | ||
| 154 | return m_pc; | ||
| 155 | } | ||
| 156 | |||
| 157 | void InterpreterVisitor::SetVec(Vec v, u128 value) { | ||
| 158 | m_fpsimd_regs[static_cast<u32>(v)] = value; | ||
| 159 | } | ||
| 160 | |||
| 161 | void InterpreterVisitor::SetReg(Reg r, u64 value) { | ||
| 162 | m_regs[static_cast<u32>(r)] = value; | ||
| 163 | } | ||
| 164 | |||
| 165 | void InterpreterVisitor::SetSp(u64 value) { | ||
| 166 | m_sp = value; | ||
| 167 | } | ||
| 168 | |||
| 169 | bool InterpreterVisitor::Ordered(size_t size, bool L, bool o0, Reg Rn, Reg Rt) { | ||
| 170 | const auto memop = L ? MemOp::Load : MemOp::Store; | ||
| 171 | const size_t elsize = 8 << size; | ||
| 172 | const size_t datasize = elsize; | ||
| 173 | |||
| 174 | // Operation | ||
| 175 | const size_t dbytes = datasize / 8; | ||
| 176 | |||
| 177 | u64 address; | ||
| 178 | if (Rn == Reg::SP) { | ||
| 179 | address = this->GetSp(); | ||
| 180 | } else { | ||
| 181 | address = this->GetReg(Rn); | ||
| 182 | } | ||
| 183 | |||
| 184 | switch (memop) { | ||
| 185 | case MemOp::Store: { | ||
| 186 | std::atomic_thread_fence(std::memory_order_seq_cst); | ||
| 187 | u64 value = this->GetReg(Rt); | ||
| 188 | m_memory.WriteBlock(address, &value, dbytes); | ||
| 189 | std::atomic_thread_fence(std::memory_order_seq_cst); | ||
| 190 | break; | ||
| 191 | } | ||
| 192 | case MemOp::Load: { | ||
| 193 | u64 value = 0; | ||
| 194 | m_memory.ReadBlock(address, &value, dbytes); | ||
| 195 | this->SetReg(Rt, value); | ||
| 196 | std::atomic_thread_fence(std::memory_order_seq_cst); | ||
| 197 | break; | ||
| 198 | } | ||
| 199 | default: | ||
| 200 | UNREACHABLE(); | ||
| 201 | } | ||
| 202 | |||
| 203 | return true; | ||
| 204 | } | ||
| 205 | |||
| 206 | bool InterpreterVisitor::STLLR(Imm<2> sz, Reg Rn, Reg Rt) { | ||
| 207 | const size_t size = sz.ZeroExtend<size_t>(); | ||
| 208 | const bool L = 0; | ||
| 209 | const bool o0 = 0; | ||
| 210 | return this->Ordered(size, L, o0, Rn, Rt); | ||
| 211 | } | ||
| 212 | |||
| 213 | bool InterpreterVisitor::STLR(Imm<2> sz, Reg Rn, Reg Rt) { | ||
| 214 | const size_t size = sz.ZeroExtend<size_t>(); | ||
| 215 | const bool L = 0; | ||
| 216 | const bool o0 = 1; | ||
| 217 | return this->Ordered(size, L, o0, Rn, Rt); | ||
| 218 | } | ||
| 219 | |||
| 220 | bool InterpreterVisitor::LDLAR(Imm<2> sz, Reg Rn, Reg Rt) { | ||
| 221 | const size_t size = sz.ZeroExtend<size_t>(); | ||
| 222 | const bool L = 1; | ||
| 223 | const bool o0 = 0; | ||
| 224 | return this->Ordered(size, L, o0, Rn, Rt); | ||
| 225 | } | ||
| 226 | |||
| 227 | bool InterpreterVisitor::LDAR(Imm<2> sz, Reg Rn, Reg Rt) { | ||
| 228 | const size_t size = sz.ZeroExtend<size_t>(); | ||
| 229 | const bool L = 1; | ||
| 230 | const bool o0 = 1; | ||
| 231 | return this->Ordered(size, L, o0, Rn, Rt); | ||
| 232 | } | ||
| 233 | |||
| 234 | bool InterpreterVisitor::LDR_lit_gen(bool opc_0, Imm<19> imm19, Reg Rt) { | ||
| 235 | const size_t size = opc_0 == 0 ? 4 : 8; | ||
| 236 | const s64 offset = Dynarmic::concatenate(imm19, Imm<2>{0}).SignExtend<s64>(); | ||
| 237 | const u64 address = this->GetPc() + offset; | ||
| 238 | |||
| 239 | u64 data = 0; | ||
| 240 | m_memory.ReadBlock(address, &data, size); | ||
| 241 | |||
| 242 | this->SetReg(Rt, data); | ||
| 243 | return true; | ||
| 244 | } | ||
| 245 | |||
| 246 | bool InterpreterVisitor::LDR_lit_fpsimd(Imm<2> opc, Imm<19> imm19, Vec Vt) { | ||
| 247 | if (opc == 0b11) { | ||
| 248 | // Unallocated encoding | ||
| 249 | return false; | ||
| 250 | } | ||
| 251 | |||
| 252 | const u64 size = 4 << opc.ZeroExtend(); | ||
| 253 | const u64 offset = imm19.SignExtend<u64>() << 2; | ||
| 254 | const u64 address = this->GetPc() + offset; | ||
| 255 | |||
| 256 | u128 data{}; | ||
| 257 | m_memory.ReadBlock(address, &data, size); | ||
| 258 | this->SetVec(Vt, data); | ||
| 259 | return true; | ||
| 260 | } | ||
| 261 | |||
| 262 | bool InterpreterVisitor::STP_LDP_gen(Imm<2> opc, bool not_postindex, bool wback, Imm<1> L, | ||
| 263 | Imm<7> imm7, Reg Rt2, Reg Rn, Reg Rt) { | ||
| 264 | if ((L == 0 && opc.Bit<0>() == 1) || opc == 0b11) { | ||
| 265 | // Unallocated encoding | ||
| 266 | return false; | ||
| 267 | } | ||
| 268 | |||
| 269 | const auto memop = L == 1 ? MemOp::Load : MemOp::Store; | ||
| 270 | if (memop == MemOp::Load && wback && (Rt == Rn || Rt2 == Rn) && Rn != Reg::R31) { | ||
| 271 | // Unpredictable instruction | ||
| 272 | return false; | ||
| 273 | } | ||
| 274 | if (memop == MemOp::Store && wback && (Rt == Rn || Rt2 == Rn) && Rn != Reg::R31) { | ||
| 275 | // Unpredictable instruction | ||
| 276 | return false; | ||
| 277 | } | ||
| 278 | if (memop == MemOp::Load && Rt == Rt2) { | ||
| 279 | // Unpredictable instruction | ||
| 280 | return false; | ||
| 281 | } | ||
| 282 | |||
| 283 | u64 address; | ||
| 284 | if (Rn == Reg::SP) { | ||
| 285 | address = this->GetSp(); | ||
| 286 | } else { | ||
| 287 | address = this->GetReg(Rn); | ||
| 288 | } | ||
| 289 | |||
| 290 | const bool postindex = !not_postindex; | ||
| 291 | const bool signed_ = opc.Bit<0>() != 0; | ||
| 292 | const size_t scale = 2 + opc.Bit<1>(); | ||
| 293 | const size_t datasize = 8 << scale; | ||
| 294 | const u64 offset = imm7.SignExtend<u64>() << scale; | ||
| 295 | |||
| 296 | if (!postindex) { | ||
| 297 | address += offset; | ||
| 298 | } | ||
| 299 | |||
| 300 | const size_t dbytes = datasize / 8; | ||
| 301 | switch (memop) { | ||
| 302 | case MemOp::Store: { | ||
| 303 | u64 data1 = this->GetReg(Rt); | ||
| 304 | u64 data2 = this->GetReg(Rt2); | ||
| 305 | m_memory.WriteBlock(address, &data1, dbytes); | ||
| 306 | m_memory.WriteBlock(address + dbytes, &data2, dbytes); | ||
| 307 | break; | ||
| 308 | } | ||
| 309 | case MemOp::Load: { | ||
| 310 | u64 data1 = 0, data2 = 0; | ||
| 311 | m_memory.ReadBlock(address, &data1, dbytes); | ||
| 312 | m_memory.ReadBlock(address + dbytes, &data2, dbytes); | ||
| 313 | if (signed_) { | ||
| 314 | this->SetReg(Rt, SignExtend(data1, datasize, 64)); | ||
| 315 | this->SetReg(Rt2, SignExtend(data2, datasize, 64)); | ||
| 316 | } else { | ||
| 317 | this->SetReg(Rt, data1); | ||
| 318 | this->SetReg(Rt2, data2); | ||
| 319 | } | ||
| 320 | break; | ||
| 321 | } | ||
| 322 | default: | ||
| 323 | UNREACHABLE(); | ||
| 324 | } | ||
| 325 | |||
| 326 | if (wback) { | ||
| 327 | if (postindex) { | ||
| 328 | address += offset; | ||
| 329 | } | ||
| 330 | |||
| 331 | if (Rn == Reg::SP) { | ||
| 332 | this->SetSp(address); | ||
| 333 | } else { | ||
| 334 | this->SetReg(Rn, address); | ||
| 335 | } | ||
| 336 | } | ||
| 337 | |||
| 338 | return true; | ||
| 339 | } | ||
| 340 | |||
| 341 | bool InterpreterVisitor::STP_LDP_fpsimd(Imm<2> opc, bool not_postindex, bool wback, Imm<1> L, | ||
| 342 | Imm<7> imm7, Vec Vt2, Reg Rn, Vec Vt) { | ||
| 343 | if (opc == 0b11) { | ||
| 344 | // Unallocated encoding | ||
| 345 | return false; | ||
| 346 | } | ||
| 347 | |||
| 348 | const auto memop = L == 1 ? MemOp::Load : MemOp::Store; | ||
| 349 | if (memop == MemOp::Load && Vt == Vt2) { | ||
| 350 | // Unpredictable instruction | ||
| 351 | return false; | ||
| 352 | } | ||
| 353 | |||
| 354 | u64 address; | ||
| 355 | if (Rn == Reg::SP) { | ||
| 356 | address = this->GetSp(); | ||
| 357 | } else { | ||
| 358 | address = this->GetReg(Rn); | ||
| 359 | } | ||
| 360 | |||
| 361 | const bool postindex = !not_postindex; | ||
| 362 | const size_t scale = 2 + opc.ZeroExtend<size_t>(); | ||
| 363 | const size_t datasize = 8 << scale; | ||
| 364 | const u64 offset = imm7.SignExtend<u64>() << scale; | ||
| 365 | const size_t dbytes = datasize / 8; | ||
| 366 | |||
| 367 | if (!postindex) { | ||
| 368 | address += offset; | ||
| 369 | } | ||
| 370 | |||
| 371 | switch (memop) { | ||
| 372 | case MemOp::Store: { | ||
| 373 | u128 data1 = VectorGetElement(this->GetVec(Vt), datasize); | ||
| 374 | u128 data2 = VectorGetElement(this->GetVec(Vt2), datasize); | ||
| 375 | m_memory.WriteBlock(address, &data1, dbytes); | ||
| 376 | m_memory.WriteBlock(address + dbytes, &data2, dbytes); | ||
| 377 | break; | ||
| 378 | } | ||
| 379 | case MemOp::Load: { | ||
| 380 | u128 data1{}, data2{}; | ||
| 381 | m_memory.ReadBlock(address, &data1, dbytes); | ||
| 382 | m_memory.ReadBlock(address + dbytes, &data2, dbytes); | ||
| 383 | this->SetVec(Vt, data1); | ||
| 384 | this->SetVec(Vt2, data2); | ||
| 385 | break; | ||
| 386 | } | ||
| 387 | default: | ||
| 388 | UNREACHABLE(); | ||
| 389 | } | ||
| 390 | |||
| 391 | if (wback) { | ||
| 392 | if (postindex) { | ||
| 393 | address += offset; | ||
| 394 | } | ||
| 395 | |||
| 396 | if (Rn == Reg::SP) { | ||
| 397 | this->SetSp(address); | ||
| 398 | } else { | ||
| 399 | this->SetReg(Rn, address); | ||
| 400 | } | ||
| 401 | } | ||
| 402 | |||
| 403 | return true; | ||
| 404 | } | ||
| 405 | |||
| 406 | bool InterpreterVisitor::RegisterImmediate(bool wback, bool postindex, size_t scale, u64 offset, | ||
| 407 | Imm<2> size, Imm<2> opc, Reg Rn, Reg Rt) { | ||
| 408 | MemOp memop; | ||
| 409 | bool signed_ = false; | ||
| 410 | size_t regsize = 0; | ||
| 411 | |||
| 412 | if (opc.Bit<1>() == 0) { | ||
| 413 | memop = opc.Bit<0>() ? MemOp::Load : MemOp::Store; | ||
| 414 | regsize = size == 0b11 ? 64 : 32; | ||
| 415 | signed_ = false; | ||
| 416 | } else if (size == 0b11) { | ||
| 417 | memop = MemOp::Prefetch; | ||
| 418 | ASSERT(!opc.Bit<0>()); | ||
| 419 | } else { | ||
| 420 | memop = MemOp::Load; | ||
| 421 | ASSERT(!(size == 0b10 && opc.Bit<0>() == 1)); | ||
| 422 | regsize = opc.Bit<0>() ? 32 : 64; | ||
| 423 | signed_ = true; | ||
| 424 | } | ||
| 425 | |||
| 426 | if (memop == MemOp::Load && wback && Rn == Rt && Rn != Reg::R31) { | ||
| 427 | // Unpredictable instruction | ||
| 428 | return false; | ||
| 429 | } | ||
| 430 | if (memop == MemOp::Store && wback && Rn == Rt && Rn != Reg::R31) { | ||
| 431 | // Unpredictable instruction | ||
| 432 | return false; | ||
| 433 | } | ||
| 434 | |||
| 435 | u64 address; | ||
| 436 | if (Rn == Reg::SP) { | ||
| 437 | address = this->GetSp(); | ||
| 438 | } else { | ||
| 439 | address = this->GetReg(Rn); | ||
| 440 | } | ||
| 441 | if (!postindex) { | ||
| 442 | address += offset; | ||
| 443 | } | ||
| 444 | |||
| 445 | const size_t datasize = 8 << scale; | ||
| 446 | switch (memop) { | ||
| 447 | case MemOp::Store: { | ||
| 448 | u64 data = this->GetReg(Rt); | ||
| 449 | m_memory.WriteBlock(address, &data, datasize / 8); | ||
| 450 | break; | ||
| 451 | } | ||
| 452 | case MemOp::Load: { | ||
| 453 | u64 data = 0; | ||
| 454 | m_memory.ReadBlock(address, &data, datasize / 8); | ||
| 455 | if (signed_) { | ||
| 456 | this->SetReg(Rt, SignExtend(data, datasize, regsize)); | ||
| 457 | } else { | ||
| 458 | this->SetReg(Rt, data); | ||
| 459 | } | ||
| 460 | break; | ||
| 461 | } | ||
| 462 | case MemOp::Prefetch: | ||
| 463 | // this->Prefetch(address, Rt) | ||
| 464 | break; | ||
| 465 | } | ||
| 466 | |||
| 467 | if (wback) { | ||
| 468 | if (postindex) { | ||
| 469 | address += offset; | ||
| 470 | } | ||
| 471 | |||
| 472 | if (Rn == Reg::SP) { | ||
| 473 | this->SetSp(address); | ||
| 474 | } else { | ||
| 475 | this->SetReg(Rn, address); | ||
| 476 | } | ||
| 477 | } | ||
| 478 | |||
| 479 | return true; | ||
| 480 | } | ||
| 481 | |||
| 482 | bool InterpreterVisitor::STRx_LDRx_imm_1(Imm<2> size, Imm<2> opc, Imm<9> imm9, bool not_postindex, | ||
| 483 | Reg Rn, Reg Rt) { | ||
| 484 | const bool wback = true; | ||
| 485 | const bool postindex = !not_postindex; | ||
| 486 | const size_t scale = size.ZeroExtend<size_t>(); | ||
| 487 | const u64 offset = imm9.SignExtend<u64>(); | ||
| 488 | |||
| 489 | return this->RegisterImmediate(wback, postindex, scale, offset, size, opc, Rn, Rt); | ||
| 490 | } | ||
| 491 | |||
| 492 | bool InterpreterVisitor::STRx_LDRx_imm_2(Imm<2> size, Imm<2> opc, Imm<12> imm12, Reg Rn, Reg Rt) { | ||
| 493 | const bool wback = false; | ||
| 494 | const bool postindex = false; | ||
| 495 | const size_t scale = size.ZeroExtend<size_t>(); | ||
| 496 | const u64 offset = imm12.ZeroExtend<u64>() << scale; | ||
| 497 | |||
| 498 | return this->RegisterImmediate(wback, postindex, scale, offset, size, opc, Rn, Rt); | ||
| 499 | } | ||
| 500 | |||
| 501 | bool InterpreterVisitor::STURx_LDURx(Imm<2> size, Imm<2> opc, Imm<9> imm9, Reg Rn, Reg Rt) { | ||
| 502 | const bool wback = false; | ||
| 503 | const bool postindex = false; | ||
| 504 | const size_t scale = size.ZeroExtend<size_t>(); | ||
| 505 | const u64 offset = imm9.SignExtend<u64>(); | ||
| 506 | |||
| 507 | return this->RegisterImmediate(wback, postindex, scale, offset, size, opc, Rn, Rt); | ||
| 508 | } | ||
| 509 | |||
| 510 | bool InterpreterVisitor::SIMDImmediate(bool wback, bool postindex, size_t scale, u64 offset, | ||
| 511 | MemOp memop, Reg Rn, Vec Vt) { | ||
| 512 | const size_t datasize = 8 << scale; | ||
| 513 | |||
| 514 | u64 address; | ||
| 515 | if (Rn == Reg::SP) { | ||
| 516 | address = this->GetSp(); | ||
| 517 | } else { | ||
| 518 | address = this->GetReg(Rn); | ||
| 519 | } | ||
| 520 | |||
| 521 | if (!postindex) { | ||
| 522 | address += offset; | ||
| 523 | } | ||
| 524 | |||
| 525 | switch (memop) { | ||
| 526 | case MemOp::Store: { | ||
| 527 | u128 data = VectorGetElement(this->GetVec(Vt), datasize); | ||
| 528 | m_memory.WriteBlock(address, &data, datasize / 8); | ||
| 529 | break; | ||
| 530 | } | ||
| 531 | case MemOp::Load: { | ||
| 532 | u128 data{}; | ||
| 533 | m_memory.ReadBlock(address, &data, datasize); | ||
| 534 | this->SetVec(Vt, data); | ||
| 535 | break; | ||
| 536 | } | ||
| 537 | default: | ||
| 538 | UNREACHABLE(); | ||
| 539 | } | ||
| 540 | |||
| 541 | if (wback) { | ||
| 542 | if (postindex) { | ||
| 543 | address += offset; | ||
| 544 | } | ||
| 545 | |||
| 546 | if (Rn == Reg::SP) { | ||
| 547 | this->SetSp(address); | ||
| 548 | } else { | ||
| 549 | this->SetReg(Rn, address); | ||
| 550 | } | ||
| 551 | } | ||
| 552 | |||
| 553 | return true; | ||
| 554 | } | ||
| 555 | |||
| 556 | bool InterpreterVisitor::STR_imm_fpsimd_1(Imm<2> size, Imm<1> opc_1, Imm<9> imm9, | ||
| 557 | bool not_postindex, Reg Rn, Vec Vt) { | ||
| 558 | const size_t scale = Dynarmic::concatenate(opc_1, size).ZeroExtend<size_t>(); | ||
| 559 | if (scale > 4) { | ||
| 560 | // Unallocated encoding | ||
| 561 | return false; | ||
| 562 | } | ||
| 563 | |||
| 564 | const bool wback = true; | ||
| 565 | const bool postindex = !not_postindex; | ||
| 566 | const u64 offset = imm9.SignExtend<u64>(); | ||
| 567 | |||
| 568 | return this->SIMDImmediate(wback, postindex, scale, offset, MemOp::Store, Rn, Vt); | ||
| 569 | } | ||
| 570 | |||
| 571 | bool InterpreterVisitor::STR_imm_fpsimd_2(Imm<2> size, Imm<1> opc_1, Imm<12> imm12, Reg Rn, | ||
| 572 | Vec Vt) { | ||
| 573 | const size_t scale = Dynarmic::concatenate(opc_1, size).ZeroExtend<size_t>(); | ||
| 574 | if (scale > 4) { | ||
| 575 | // Unallocated encoding | ||
| 576 | return false; | ||
| 577 | } | ||
| 578 | |||
| 579 | const bool wback = false; | ||
| 580 | const bool postindex = false; | ||
| 581 | const u64 offset = imm12.ZeroExtend<u64>() << scale; | ||
| 582 | |||
| 583 | return this->SIMDImmediate(wback, postindex, scale, offset, MemOp::Store, Rn, Vt); | ||
| 584 | } | ||
| 585 | |||
| 586 | bool InterpreterVisitor::LDR_imm_fpsimd_1(Imm<2> size, Imm<1> opc_1, Imm<9> imm9, | ||
| 587 | bool not_postindex, Reg Rn, Vec Vt) { | ||
| 588 | const size_t scale = Dynarmic::concatenate(opc_1, size).ZeroExtend<size_t>(); | ||
| 589 | if (scale > 4) { | ||
| 590 | // Unallocated encoding | ||
| 591 | return false; | ||
| 592 | } | ||
| 593 | |||
| 594 | const bool wback = true; | ||
| 595 | const bool postindex = !not_postindex; | ||
| 596 | const u64 offset = imm9.SignExtend<u64>(); | ||
| 597 | |||
| 598 | return this->SIMDImmediate(wback, postindex, scale, offset, MemOp::Load, Rn, Vt); | ||
| 599 | } | ||
| 600 | |||
| 601 | bool InterpreterVisitor::LDR_imm_fpsimd_2(Imm<2> size, Imm<1> opc_1, Imm<12> imm12, Reg Rn, | ||
| 602 | Vec Vt) { | ||
| 603 | const size_t scale = Dynarmic::concatenate(opc_1, size).ZeroExtend<size_t>(); | ||
| 604 | if (scale > 4) { | ||
| 605 | // Unallocated encoding | ||
| 606 | return false; | ||
| 607 | } | ||
| 608 | |||
| 609 | const bool wback = false; | ||
| 610 | const bool postindex = false; | ||
| 611 | const u64 offset = imm12.ZeroExtend<u64>() << scale; | ||
| 612 | |||
| 613 | return this->SIMDImmediate(wback, postindex, scale, offset, MemOp::Load, Rn, Vt); | ||
| 614 | } | ||
| 615 | |||
| 616 | bool InterpreterVisitor::STUR_fpsimd(Imm<2> size, Imm<1> opc_1, Imm<9> imm9, Reg Rn, Vec Vt) { | ||
| 617 | const size_t scale = Dynarmic::concatenate(opc_1, size).ZeroExtend<size_t>(); | ||
| 618 | if (scale > 4) { | ||
| 619 | // Unallocated encoding | ||
| 620 | return false; | ||
| 621 | } | ||
| 622 | |||
| 623 | const bool wback = false; | ||
| 624 | const bool postindex = false; | ||
| 625 | const u64 offset = imm9.SignExtend<u64>(); | ||
| 626 | |||
| 627 | return this->SIMDImmediate(wback, postindex, scale, offset, MemOp::Store, Rn, Vt); | ||
| 628 | } | ||
| 629 | |||
| 630 | bool InterpreterVisitor::LDUR_fpsimd(Imm<2> size, Imm<1> opc_1, Imm<9> imm9, Reg Rn, Vec Vt) { | ||
| 631 | const size_t scale = Dynarmic::concatenate(opc_1, size).ZeroExtend<size_t>(); | ||
| 632 | if (scale > 4) { | ||
| 633 | // Unallocated encoding | ||
| 634 | return false; | ||
| 635 | } | ||
| 636 | |||
| 637 | const bool wback = false; | ||
| 638 | const bool postindex = false; | ||
| 639 | const u64 offset = imm9.SignExtend<u64>(); | ||
| 640 | |||
| 641 | return this->SIMDImmediate(wback, postindex, scale, offset, MemOp::Load, Rn, Vt); | ||
| 642 | } | ||
| 643 | |||
| 644 | bool InterpreterVisitor::RegisterOffset(size_t scale, u8 shift, Imm<2> size, Imm<1> opc_1, | ||
| 645 | Imm<1> opc_0, Reg Rm, Imm<3> option, Reg Rn, Reg Rt) { | ||
| 646 | MemOp memop; | ||
| 647 | size_t regsize = 64; | ||
| 648 | bool signed_ = false; | ||
| 649 | |||
| 650 | if (opc_1 == 0) { | ||
| 651 | memop = opc_0 == 1 ? MemOp::Load : MemOp::Store; | ||
| 652 | regsize = size == 0b11 ? 64 : 32; | ||
| 653 | signed_ = false; | ||
| 654 | } else if (size == 0b11) { | ||
| 655 | memop = MemOp::Prefetch; | ||
| 656 | if (opc_0 == 1) { | ||
| 657 | // Unallocated encoding | ||
| 658 | return false; | ||
| 659 | } | ||
| 660 | } else { | ||
| 661 | memop = MemOp::Load; | ||
| 662 | if (size == 0b10 && opc_0 == 1) { | ||
| 663 | // Unallocated encoding | ||
| 664 | return false; | ||
| 665 | } | ||
| 666 | regsize = opc_0 == 1 ? 32 : 64; | ||
| 667 | signed_ = true; | ||
| 668 | } | ||
| 669 | |||
| 670 | const size_t datasize = 8 << scale; | ||
| 671 | |||
| 672 | // Operation | ||
| 673 | const u64 offset = this->ExtendReg(64, Rm, option, shift); | ||
| 674 | |||
| 675 | u64 address; | ||
| 676 | if (Rn == Reg::SP) { | ||
| 677 | address = this->GetSp(); | ||
| 678 | } else { | ||
| 679 | address = this->GetReg(Rn); | ||
| 680 | } | ||
| 681 | address += offset; | ||
| 682 | |||
| 683 | switch (memop) { | ||
| 684 | case MemOp::Store: { | ||
| 685 | u64 data = this->GetReg(Rt); | ||
| 686 | m_memory.WriteBlock(address, &data, datasize / 8); | ||
| 687 | break; | ||
| 688 | } | ||
| 689 | case MemOp::Load: { | ||
| 690 | u64 data = 0; | ||
| 691 | m_memory.ReadBlock(address, &data, datasize / 8); | ||
| 692 | if (signed_) { | ||
| 693 | this->SetReg(Rt, SignExtend(data, datasize, regsize)); | ||
| 694 | } else { | ||
| 695 | this->SetReg(Rt, data); | ||
| 696 | } | ||
| 697 | break; | ||
| 698 | } | ||
| 699 | case MemOp::Prefetch: | ||
| 700 | break; | ||
| 701 | } | ||
| 702 | |||
| 703 | return true; | ||
| 704 | } | ||
| 705 | |||
| 706 | bool InterpreterVisitor::STRx_reg(Imm<2> size, Imm<1> opc_1, Reg Rm, Imm<3> option, bool S, Reg Rn, | ||
| 707 | Reg Rt) { | ||
| 708 | const Imm<1> opc_0{0}; | ||
| 709 | const size_t scale = size.ZeroExtend<size_t>(); | ||
| 710 | const u8 shift = S ? static_cast<u8>(scale) : 0; | ||
| 711 | if (!option.Bit<1>()) { | ||
| 712 | // Unallocated encoding | ||
| 713 | return false; | ||
| 714 | } | ||
| 715 | return this->RegisterOffset(scale, shift, size, opc_1, opc_0, Rm, option, Rn, Rt); | ||
| 716 | } | ||
| 717 | |||
| 718 | bool InterpreterVisitor::LDRx_reg(Imm<2> size, Imm<1> opc_1, Reg Rm, Imm<3> option, bool S, Reg Rn, | ||
| 719 | Reg Rt) { | ||
| 720 | const Imm<1> opc_0{1}; | ||
| 721 | const size_t scale = size.ZeroExtend<size_t>(); | ||
| 722 | const u8 shift = S ? static_cast<u8>(scale) : 0; | ||
| 723 | if (!option.Bit<1>()) { | ||
| 724 | // Unallocated encoding | ||
| 725 | return false; | ||
| 726 | } | ||
| 727 | return this->RegisterOffset(scale, shift, size, opc_1, opc_0, Rm, option, Rn, Rt); | ||
| 728 | } | ||
| 729 | |||
| 730 | bool InterpreterVisitor::SIMDOffset(size_t scale, u8 shift, Imm<1> opc_0, Reg Rm, Imm<3> option, | ||
| 731 | Reg Rn, Vec Vt) { | ||
| 732 | const auto memop = opc_0 == 1 ? MemOp::Load : MemOp::Store; | ||
| 733 | const size_t datasize = 8 << scale; | ||
| 734 | |||
| 735 | // Operation | ||
| 736 | const u64 offset = this->ExtendReg(64, Rm, option, shift); | ||
| 737 | |||
| 738 | u64 address; | ||
| 739 | if (Rn == Reg::SP) { | ||
| 740 | address = this->GetSp(); | ||
| 741 | } else { | ||
| 742 | address = this->GetReg(Rn); | ||
| 743 | } | ||
| 744 | address += offset; | ||
| 745 | |||
| 746 | switch (memop) { | ||
| 747 | case MemOp::Store: { | ||
| 748 | u128 data = VectorGetElement(this->GetVec(Vt), datasize); | ||
| 749 | m_memory.WriteBlock(address, &data, datasize / 8); | ||
| 750 | break; | ||
| 751 | } | ||
| 752 | case MemOp::Load: { | ||
| 753 | u128 data{}; | ||
| 754 | m_memory.ReadBlock(address, &data, datasize / 8); | ||
| 755 | this->SetVec(Vt, data); | ||
| 756 | break; | ||
| 757 | } | ||
| 758 | default: | ||
| 759 | UNREACHABLE(); | ||
| 760 | } | ||
| 761 | |||
| 762 | return true; | ||
| 763 | } | ||
| 764 | |||
| 765 | bool InterpreterVisitor::STR_reg_fpsimd(Imm<2> size, Imm<1> opc_1, Reg Rm, Imm<3> option, bool S, | ||
| 766 | Reg Rn, Vec Vt) { | ||
| 767 | const Imm<1> opc_0{0}; | ||
| 768 | const size_t scale = Dynarmic::concatenate(opc_1, size).ZeroExtend<size_t>(); | ||
| 769 | if (scale > 4) { | ||
| 770 | // Unallocated encoding | ||
| 771 | return false; | ||
| 772 | } | ||
| 773 | const u8 shift = S ? static_cast<u8>(scale) : 0; | ||
| 774 | if (!option.Bit<1>()) { | ||
| 775 | // Unallocated encoding | ||
| 776 | return false; | ||
| 777 | } | ||
| 778 | return this->SIMDOffset(scale, shift, opc_0, Rm, option, Rn, Vt); | ||
| 779 | } | ||
| 780 | |||
| 781 | bool InterpreterVisitor::LDR_reg_fpsimd(Imm<2> size, Imm<1> opc_1, Reg Rm, Imm<3> option, bool S, | ||
| 782 | Reg Rn, Vec Vt) { | ||
| 783 | const Imm<1> opc_0{1}; | ||
| 784 | const size_t scale = Dynarmic::concatenate(opc_1, size).ZeroExtend<size_t>(); | ||
| 785 | if (scale > 4) { | ||
| 786 | // Unallocated encoding | ||
| 787 | return false; | ||
| 788 | } | ||
| 789 | const u8 shift = S ? static_cast<u8>(scale) : 0; | ||
| 790 | if (!option.Bit<1>()) { | ||
| 791 | // Unallocated encoding | ||
| 792 | return false; | ||
| 793 | } | ||
| 794 | return this->SIMDOffset(scale, shift, opc_0, Rm, option, Rn, Vt); | ||
| 795 | } | ||
| 796 | |||
| 797 | std::optional<u64> MatchAndExecuteOneInstruction(Core::Memory::Memory& memory, mcontext_t* context, | ||
| 798 | fpsimd_context* fpsimd_context) { | ||
| 799 | // Construct the interpreter. | ||
| 800 | std::span<u64, 31> regs(reinterpret_cast<u64*>(context->regs), 31); | ||
| 801 | std::span<u128, 32> vregs(reinterpret_cast<u128*>(fpsimd_context->vregs), 32); | ||
| 802 | u64& sp = *reinterpret_cast<u64*>(&context->sp); | ||
| 803 | const u64& pc = *reinterpret_cast<u64*>(&context->pc); | ||
| 804 | |||
| 805 | InterpreterVisitor visitor(memory, regs, vregs, sp, pc); | ||
| 806 | |||
| 807 | // Read the instruction at the program counter. | ||
| 808 | u32 instruction = memory.Read32(pc); | ||
| 809 | bool was_executed = false; | ||
| 810 | |||
| 811 | // Interpret the instruction. | ||
| 812 | if (auto decoder = Dynarmic::A64::Decode<VisitorBase>(instruction)) { | ||
| 813 | was_executed = decoder->get().call(visitor, instruction); | ||
| 814 | } else { | ||
| 815 | LOG_ERROR(Core_ARM, "Unallocated encoding: {:#x}", instruction); | ||
| 816 | } | ||
| 817 | |||
| 818 | if (was_executed) { | ||
| 819 | return pc + 4; | ||
| 820 | } | ||
| 821 | |||
| 822 | return std::nullopt; | ||
| 823 | } | ||
| 824 | |||
| 825 | } // namespace Core | ||
diff --git a/src/core/arm/nce/interpreter_visitor.h b/src/core/arm/nce/interpreter_visitor.h new file mode 100644 index 000000000..f90d876ab --- /dev/null +++ b/src/core/arm/nce/interpreter_visitor.h | |||
| @@ -0,0 +1,103 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-FileCopyrightText: Copyright 2023 merryhime <https://mary.rs> | ||
| 3 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <signal.h> | ||
| 8 | #include <unistd.h> | ||
| 9 | |||
| 10 | #include "core/arm/nce/visitor_base.h" | ||
| 11 | |||
| 12 | namespace Core { | ||
| 13 | |||
| 14 | namespace Memory { | ||
| 15 | class Memory; | ||
| 16 | } | ||
| 17 | |||
| 18 | class InterpreterVisitor final : public VisitorBase { | ||
| 19 | public: | ||
| 20 | explicit InterpreterVisitor(Core::Memory::Memory& memory, std::span<u64, 31> regs, | ||
| 21 | std::span<u128, 32> fpsimd_regs, u64& sp, const u64& pc) | ||
| 22 | : m_memory(memory), m_regs(regs), m_fpsimd_regs(fpsimd_regs), m_sp(sp), m_pc(pc) {} | ||
| 23 | ~InterpreterVisitor() override = default; | ||
| 24 | |||
| 25 | enum class MemOp { | ||
| 26 | Load, | ||
| 27 | Store, | ||
| 28 | Prefetch, | ||
| 29 | }; | ||
| 30 | |||
| 31 | u128 GetVec(Vec v); | ||
| 32 | u64 GetReg(Reg r); | ||
| 33 | u64 GetSp(); | ||
| 34 | u64 GetPc(); | ||
| 35 | |||
| 36 | void SetVec(Vec v, u128 value); | ||
| 37 | void SetReg(Reg r, u64 value); | ||
| 38 | void SetSp(u64 value); | ||
| 39 | |||
| 40 | u64 ExtendReg(size_t bitsize, Reg reg, Imm<3> option, u8 shift); | ||
| 41 | |||
| 42 | // Loads and stores - Load/Store Exclusive | ||
| 43 | bool Ordered(size_t size, bool L, bool o0, Reg Rn, Reg Rt); | ||
| 44 | bool STLLR(Imm<2> size, Reg Rn, Reg Rt) override; | ||
| 45 | bool STLR(Imm<2> size, Reg Rn, Reg Rt) override; | ||
| 46 | bool LDLAR(Imm<2> size, Reg Rn, Reg Rt) override; | ||
| 47 | bool LDAR(Imm<2> size, Reg Rn, Reg Rt) override; | ||
| 48 | |||
| 49 | // Loads and stores - Load register (literal) | ||
| 50 | bool LDR_lit_gen(bool opc_0, Imm<19> imm19, Reg Rt) override; | ||
| 51 | bool LDR_lit_fpsimd(Imm<2> opc, Imm<19> imm19, Vec Vt) override; | ||
| 52 | |||
| 53 | // Loads and stores - Load/Store register pair | ||
| 54 | bool STP_LDP_gen(Imm<2> opc, bool not_postindex, bool wback, Imm<1> L, Imm<7> imm7, Reg Rt2, | ||
| 55 | Reg Rn, Reg Rt) override; | ||
| 56 | bool STP_LDP_fpsimd(Imm<2> opc, bool not_postindex, bool wback, Imm<1> L, Imm<7> imm7, Vec Vt2, | ||
| 57 | Reg Rn, Vec Vt) override; | ||
| 58 | |||
| 59 | // Loads and stores - Load/Store register (immediate) | ||
| 60 | bool RegisterImmediate(bool wback, bool postindex, size_t scale, u64 offset, Imm<2> size, | ||
| 61 | Imm<2> opc, Reg Rn, Reg Rt); | ||
| 62 | bool STRx_LDRx_imm_1(Imm<2> size, Imm<2> opc, Imm<9> imm9, bool not_postindex, Reg Rn, | ||
| 63 | Reg Rt) override; | ||
| 64 | bool STRx_LDRx_imm_2(Imm<2> size, Imm<2> opc, Imm<12> imm12, Reg Rn, Reg Rt) override; | ||
| 65 | bool STURx_LDURx(Imm<2> size, Imm<2> opc, Imm<9> imm9, Reg Rn, Reg Rt) override; | ||
| 66 | |||
| 67 | bool SIMDImmediate(bool wback, bool postindex, size_t scale, u64 offset, MemOp memop, Reg Rn, | ||
| 68 | Vec Vt); | ||
| 69 | bool STR_imm_fpsimd_1(Imm<2> size, Imm<1> opc_1, Imm<9> imm9, bool not_postindex, Reg Rn, | ||
| 70 | Vec Vt) override; | ||
| 71 | bool STR_imm_fpsimd_2(Imm<2> size, Imm<1> opc_1, Imm<12> imm12, Reg Rn, Vec Vt) override; | ||
| 72 | bool LDR_imm_fpsimd_1(Imm<2> size, Imm<1> opc_1, Imm<9> imm9, bool not_postindex, Reg Rn, | ||
| 73 | Vec Vt) override; | ||
| 74 | bool LDR_imm_fpsimd_2(Imm<2> size, Imm<1> opc_1, Imm<12> imm12, Reg Rn, Vec Vt) override; | ||
| 75 | bool STUR_fpsimd(Imm<2> size, Imm<1> opc_1, Imm<9> imm9, Reg Rn, Vec Vt) override; | ||
| 76 | bool LDUR_fpsimd(Imm<2> size, Imm<1> opc_1, Imm<9> imm9, Reg Rn, Vec Vt) override; | ||
| 77 | |||
| 78 | // Loads and stores - Load/Store register (register offset) | ||
| 79 | bool RegisterOffset(size_t scale, u8 shift, Imm<2> size, Imm<1> opc_1, Imm<1> opc_0, Reg Rm, | ||
| 80 | Imm<3> option, Reg Rn, Reg Rt); | ||
| 81 | bool STRx_reg(Imm<2> size, Imm<1> opc_1, Reg Rm, Imm<3> option, bool S, Reg Rn, | ||
| 82 | Reg Rt) override; | ||
| 83 | bool LDRx_reg(Imm<2> size, Imm<1> opc_1, Reg Rm, Imm<3> option, bool S, Reg Rn, | ||
| 84 | Reg Rt) override; | ||
| 85 | |||
| 86 | bool SIMDOffset(size_t scale, u8 shift, Imm<1> opc_0, Reg Rm, Imm<3> option, Reg Rn, Vec Vt); | ||
| 87 | bool STR_reg_fpsimd(Imm<2> size, Imm<1> opc_1, Reg Rm, Imm<3> option, bool S, Reg Rn, | ||
| 88 | Vec Vt) override; | ||
| 89 | bool LDR_reg_fpsimd(Imm<2> size, Imm<1> opc_1, Reg Rm, Imm<3> option, bool S, Reg Rn, | ||
| 90 | Vec Vt) override; | ||
| 91 | |||
| 92 | private: | ||
| 93 | Core::Memory::Memory& m_memory; | ||
| 94 | std::span<u64, 31> m_regs; | ||
| 95 | std::span<u128, 32> m_fpsimd_regs; | ||
| 96 | u64& m_sp; | ||
| 97 | const u64& m_pc; | ||
| 98 | }; | ||
| 99 | |||
| 100 | std::optional<u64> MatchAndExecuteOneInstruction(Core::Memory::Memory& memory, mcontext_t* context, | ||
| 101 | fpsimd_context* fpsimd_context); | ||
| 102 | |||
| 103 | } // namespace Core | ||
diff --git a/src/core/arm/nce/visitor_base.h b/src/core/arm/nce/visitor_base.h new file mode 100644 index 000000000..8fb032912 --- /dev/null +++ b/src/core/arm/nce/visitor_base.h | |||
| @@ -0,0 +1,2777 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-FileCopyrightText: Copyright 2023 merryhime <https://mary.rs> | ||
| 3 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <dynarmic/frontend/A64/a64_types.h> | ||
| 8 | #include <dynarmic/frontend/imm.h> | ||
| 9 | |||
| 10 | namespace Core { | ||
| 11 | |||
| 12 | class VisitorBase { | ||
| 13 | public: | ||
| 14 | using instruction_return_type = bool; | ||
| 15 | |||
| 16 | template <size_t BitSize> | ||
| 17 | using Imm = Dynarmic::Imm<BitSize>; | ||
| 18 | using Reg = Dynarmic::A64::Reg; | ||
| 19 | using Vec = Dynarmic::A64::Vec; | ||
| 20 | using Cond = Dynarmic::A64::Cond; | ||
| 21 | |||
| 22 | virtual ~VisitorBase() {} | ||
| 23 | |||
| 24 | virtual bool UnallocatedEncoding() { | ||
| 25 | return false; | ||
| 26 | } | ||
| 27 | |||
| 28 | // Data processing - Immediate - PC relative addressing | ||
| 29 | virtual bool ADR(Imm<2> immlo, Imm<19> immhi, Reg Rd) { | ||
| 30 | return false; | ||
| 31 | } | ||
| 32 | virtual bool ADRP(Imm<2> immlo, Imm<19> immhi, Reg Rd) { | ||
| 33 | return false; | ||
| 34 | } | ||
| 35 | |||
| 36 | // Data processing - Immediate - Add/Sub (with tag) | ||
| 37 | virtual bool ADDG(Imm<6> offset_imm, Imm<4> tag_offset, Reg Rn, Reg Rd) { | ||
| 38 | return false; | ||
| 39 | } | ||
| 40 | virtual bool SUBG(Imm<6> offset_imm, Imm<4> tag_offset, Reg Rn, Reg Rd) { | ||
| 41 | return false; | ||
| 42 | } | ||
| 43 | |||
| 44 | // Data processing - Immediate - Add/Sub | ||
| 45 | virtual bool ADD_imm(bool sf, Imm<2> shift, Imm<12> imm12, Reg Rn, Reg Rd) { | ||
| 46 | return false; | ||
| 47 | } | ||
| 48 | virtual bool ADDS_imm(bool sf, Imm<2> shift, Imm<12> imm12, Reg Rn, Reg Rd) { | ||
| 49 | return false; | ||
| 50 | } | ||
| 51 | virtual bool SUB_imm(bool sf, Imm<2> shift, Imm<12> imm12, Reg Rn, Reg Rd) { | ||
| 52 | return false; | ||
| 53 | } | ||
| 54 | virtual bool SUBS_imm(bool sf, Imm<2> shift, Imm<12> imm12, Reg Rn, Reg Rd) { | ||
| 55 | return false; | ||
| 56 | } | ||
| 57 | |||
| 58 | // Data processing - Immediate - Logical | ||
| 59 | virtual bool AND_imm(bool sf, bool N, Imm<6> immr, Imm<6> imms, Reg Rn, Reg Rd) { | ||
| 60 | return false; | ||
| 61 | } | ||
| 62 | virtual bool ORR_imm(bool sf, bool N, Imm<6> immr, Imm<6> imms, Reg Rn, Reg Rd) { | ||
| 63 | return false; | ||
| 64 | } | ||
| 65 | virtual bool EOR_imm(bool sf, bool N, Imm<6> immr, Imm<6> imms, Reg Rn, Reg Rd) { | ||
| 66 | return false; | ||
| 67 | } | ||
| 68 | virtual bool ANDS_imm(bool sf, bool N, Imm<6> immr, Imm<6> imms, Reg Rn, Reg Rd) { | ||
| 69 | return false; | ||
| 70 | } | ||
| 71 | |||
| 72 | // Data processing - Immediate - Move Wide | ||
| 73 | virtual bool MOVN(bool sf, Imm<2> hw, Imm<16> imm16, Reg Rd) { | ||
| 74 | return false; | ||
| 75 | } | ||
| 76 | virtual bool MOVZ(bool sf, Imm<2> hw, Imm<16> imm16, Reg Rd) { | ||
| 77 | return false; | ||
| 78 | } | ||
| 79 | virtual bool MOVK(bool sf, Imm<2> hw, Imm<16> imm16, Reg Rd) { | ||
| 80 | return false; | ||
| 81 | } | ||
| 82 | |||
| 83 | // Data processing - Immediate - Bitfield | ||
| 84 | virtual bool SBFM(bool sf, bool N, Imm<6> immr, Imm<6> imms, Reg Rn, Reg Rd) { | ||
| 85 | return false; | ||
| 86 | } | ||
| 87 | virtual bool BFM(bool sf, bool N, Imm<6> immr, Imm<6> imms, Reg Rn, Reg Rd) { | ||
| 88 | return false; | ||
| 89 | } | ||
| 90 | virtual bool UBFM(bool sf, bool N, Imm<6> immr, Imm<6> imms, Reg Rn, Reg Rd) { | ||
| 91 | return false; | ||
| 92 | } | ||
| 93 | virtual bool ASR_1(Imm<5> immr, Reg Rn, Reg Rd) { | ||
| 94 | return false; | ||
| 95 | } | ||
| 96 | virtual bool ASR_2(Imm<6> immr, Reg Rn, Reg Rd) { | ||
| 97 | return false; | ||
| 98 | } | ||
| 99 | virtual bool SXTB_1(Reg Rn, Reg Rd) { | ||
| 100 | return false; | ||
| 101 | } | ||
| 102 | virtual bool SXTB_2(Reg Rn, Reg Rd) { | ||
| 103 | return false; | ||
| 104 | } | ||
| 105 | virtual bool SXTH_1(Reg Rn, Reg Rd) { | ||
| 106 | return false; | ||
| 107 | } | ||
| 108 | virtual bool SXTH_2(Reg Rn, Reg Rd) { | ||
| 109 | return false; | ||
| 110 | } | ||
| 111 | virtual bool SXTW(Reg Rn, Reg Rd) { | ||
| 112 | return false; | ||
| 113 | } | ||
| 114 | |||
| 115 | // Data processing - Immediate - Extract | ||
| 116 | virtual bool EXTR(bool sf, bool N, Reg Rm, Imm<6> imms, Reg Rn, Reg Rd) { | ||
| 117 | return false; | ||
| 118 | } | ||
| 119 | |||
| 120 | // Conditional branch | ||
| 121 | virtual bool B_cond(Imm<19> imm19, Cond cond) { | ||
| 122 | return false; | ||
| 123 | } | ||
| 124 | |||
| 125 | // Exception generation | ||
| 126 | virtual bool SVC(Imm<16> imm16) { | ||
| 127 | return false; | ||
| 128 | } | ||
| 129 | virtual bool HVC(Imm<16> imm16) { | ||
| 130 | return false; | ||
| 131 | } | ||
| 132 | virtual bool SMC(Imm<16> imm16) { | ||
| 133 | return false; | ||
| 134 | } | ||
| 135 | virtual bool BRK(Imm<16> imm16) { | ||
| 136 | return false; | ||
| 137 | } | ||
| 138 | virtual bool HLT(Imm<16> imm16) { | ||
| 139 | return false; | ||
| 140 | } | ||
| 141 | virtual bool DCPS1(Imm<16> imm16) { | ||
| 142 | return false; | ||
| 143 | } | ||
| 144 | virtual bool DCPS2(Imm<16> imm16) { | ||
| 145 | return false; | ||
| 146 | } | ||
| 147 | virtual bool DCPS3(Imm<16> imm16) { | ||
| 148 | return false; | ||
| 149 | } | ||
| 150 | |||
| 151 | // System | ||
| 152 | virtual bool MSR_imm(Imm<3> op1, Imm<4> CRm, Imm<3> op2) { | ||
| 153 | return false; | ||
| 154 | } | ||
| 155 | virtual bool HINT(Imm<4> CRm, Imm<3> op2) { | ||
| 156 | return false; | ||
| 157 | } | ||
| 158 | virtual bool NOP() { | ||
| 159 | return false; | ||
| 160 | } | ||
| 161 | virtual bool YIELD() { | ||
| 162 | return false; | ||
| 163 | } | ||
| 164 | virtual bool WFE() { | ||
| 165 | return false; | ||
| 166 | } | ||
| 167 | virtual bool WFI() { | ||
| 168 | return false; | ||
| 169 | } | ||
| 170 | virtual bool SEV() { | ||
| 171 | return false; | ||
| 172 | } | ||
| 173 | virtual bool SEVL() { | ||
| 174 | return false; | ||
| 175 | } | ||
| 176 | virtual bool XPAC_1(bool D, Reg Rd) { | ||
| 177 | return false; | ||
| 178 | } | ||
| 179 | virtual bool XPAC_2() { | ||
| 180 | return false; | ||
| 181 | } | ||
| 182 | virtual bool PACIA_1(bool Z, Reg Rn, Reg Rd) { | ||
| 183 | return false; | ||
| 184 | } | ||
| 185 | virtual bool PACIA_2() { | ||
| 186 | return false; | ||
| 187 | } | ||
| 188 | virtual bool PACIB_1(bool Z, Reg Rn, Reg Rd) { | ||
| 189 | return false; | ||
| 190 | } | ||
| 191 | virtual bool PACIB_2() { | ||
| 192 | return false; | ||
| 193 | } | ||
| 194 | virtual bool AUTIA_1(bool Z, Reg Rn, Reg Rd) { | ||
| 195 | return false; | ||
| 196 | } | ||
| 197 | virtual bool AUTIA_2() { | ||
| 198 | return false; | ||
| 199 | } | ||
| 200 | virtual bool AUTIB_1(bool Z, Reg Rn, Reg Rd) { | ||
| 201 | return false; | ||
| 202 | } | ||
| 203 | virtual bool AUTIB_2() { | ||
| 204 | return false; | ||
| 205 | } | ||
| 206 | virtual bool BTI(Imm<2> upper_op2) { | ||
| 207 | return false; | ||
| 208 | } | ||
| 209 | virtual bool ESB() { | ||
| 210 | return false; | ||
| 211 | } | ||
| 212 | virtual bool PSB() { | ||
| 213 | return false; | ||
| 214 | } | ||
| 215 | virtual bool TSB() { | ||
| 216 | return false; | ||
| 217 | } | ||
| 218 | virtual bool CSDB() { | ||
| 219 | return false; | ||
| 220 | } | ||
| 221 | virtual bool CLREX(Imm<4> CRm) { | ||
| 222 | return false; | ||
| 223 | } | ||
| 224 | virtual bool DSB(Imm<4> CRm) { | ||
| 225 | return false; | ||
| 226 | } | ||
| 227 | virtual bool SSBB() { | ||
| 228 | return false; | ||
| 229 | } | ||
| 230 | virtual bool PSSBB() { | ||
| 231 | return false; | ||
| 232 | } | ||
| 233 | virtual bool DMB(Imm<4> CRm) { | ||
| 234 | return false; | ||
| 235 | } | ||
| 236 | virtual bool ISB(Imm<4> CRm) { | ||
| 237 | return false; | ||
| 238 | } | ||
| 239 | virtual bool SYS(Imm<3> op1, Imm<4> CRn, Imm<4> CRm, Imm<3> op2, Reg Rt) { | ||
| 240 | return false; | ||
| 241 | } | ||
| 242 | virtual bool SB() { | ||
| 243 | return false; | ||
| 244 | } | ||
| 245 | virtual bool MSR_reg(Imm<1> o0, Imm<3> op1, Imm<4> CRn, Imm<4> CRm, Imm<3> op2, Reg Rt) { | ||
| 246 | return false; | ||
| 247 | } | ||
| 248 | virtual bool SYSL(Imm<3> op1, Imm<4> CRn, Imm<4> CRm, Imm<3> op2, Reg Rt) { | ||
| 249 | return false; | ||
| 250 | } | ||
| 251 | virtual bool MRS(Imm<1> o0, Imm<3> op1, Imm<4> CRn, Imm<4> CRm, Imm<3> op2, Reg Rt) { | ||
| 252 | return false; | ||
| 253 | } | ||
| 254 | |||
| 255 | // System - Flag manipulation instructions | ||
| 256 | virtual bool CFINV() { | ||
| 257 | return false; | ||
| 258 | } | ||
| 259 | virtual bool RMIF(Imm<6> lsb, Reg Rn, Imm<4> mask) { | ||
| 260 | return false; | ||
| 261 | } | ||
| 262 | virtual bool SETF8(Reg Rn) { | ||
| 263 | return false; | ||
| 264 | } | ||
| 265 | virtual bool SETF16(Reg Rn) { | ||
| 266 | return false; | ||
| 267 | } | ||
| 268 | |||
| 269 | // System - Flag format instructions | ||
| 270 | virtual bool XAFlag() { | ||
| 271 | return false; | ||
| 272 | } | ||
| 273 | virtual bool AXFlag() { | ||
| 274 | return false; | ||
| 275 | } | ||
| 276 | |||
| 277 | // SYS: Data Cache | ||
| 278 | virtual bool DC_IVAC(Reg Rt) { | ||
| 279 | return false; | ||
| 280 | } | ||
| 281 | virtual bool DC_ISW(Reg Rt) { | ||
| 282 | return false; | ||
| 283 | } | ||
| 284 | virtual bool DC_CSW(Reg Rt) { | ||
| 285 | return false; | ||
| 286 | } | ||
| 287 | virtual bool DC_CISW(Reg Rt) { | ||
| 288 | return false; | ||
| 289 | } | ||
| 290 | virtual bool DC_ZVA(Reg Rt) { | ||
| 291 | return false; | ||
| 292 | } | ||
| 293 | virtual bool DC_CVAC(Reg Rt) { | ||
| 294 | return false; | ||
| 295 | } | ||
| 296 | virtual bool DC_CVAU(Reg Rt) { | ||
| 297 | return false; | ||
| 298 | } | ||
| 299 | virtual bool DC_CVAP(Reg Rt) { | ||
| 300 | return false; | ||
| 301 | } | ||
| 302 | virtual bool DC_CIVAC(Reg Rt) { | ||
| 303 | return false; | ||
| 304 | } | ||
| 305 | |||
| 306 | // SYS: Instruction Cache | ||
| 307 | virtual bool IC_IALLU() { | ||
| 308 | return false; | ||
| 309 | } | ||
| 310 | virtual bool IC_IALLUIS() { | ||
| 311 | return false; | ||
| 312 | } | ||
| 313 | virtual bool IC_IVAU(Reg Rt) { | ||
| 314 | return false; | ||
| 315 | } | ||
| 316 | |||
| 317 | // Unconditional branch (Register) | ||
| 318 | virtual bool BR(Reg Rn) { | ||
| 319 | return false; | ||
| 320 | } | ||
| 321 | virtual bool BRA(bool Z, bool M, Reg Rn, Reg Rm) { | ||
| 322 | return false; | ||
| 323 | } | ||
| 324 | virtual bool BLR(Reg Rn) { | ||
| 325 | return false; | ||
| 326 | } | ||
| 327 | virtual bool BLRA(bool Z, bool M, Reg Rn, Reg Rm) { | ||
| 328 | return false; | ||
| 329 | } | ||
| 330 | virtual bool RET(Reg Rn) { | ||
| 331 | return false; | ||
| 332 | } | ||
| 333 | virtual bool RETA(bool M) { | ||
| 334 | return false; | ||
| 335 | } | ||
| 336 | virtual bool ERET() { | ||
| 337 | return false; | ||
| 338 | } | ||
| 339 | virtual bool ERETA(bool M) { | ||
| 340 | return false; | ||
| 341 | } | ||
| 342 | virtual bool DRPS() { | ||
| 343 | return false; | ||
| 344 | } | ||
| 345 | |||
| 346 | // Unconditional branch (immediate) | ||
| 347 | virtual bool B_uncond(Imm<26> imm26) { | ||
| 348 | return false; | ||
| 349 | } | ||
| 350 | virtual bool BL(Imm<26> imm26) { | ||
| 351 | return false; | ||
| 352 | } | ||
| 353 | |||
| 354 | // Compare and branch (immediate) | ||
| 355 | virtual bool CBZ(bool sf, Imm<19> imm19, Reg Rt) { | ||
| 356 | return false; | ||
| 357 | } | ||
| 358 | virtual bool CBNZ(bool sf, Imm<19> imm19, Reg Rt) { | ||
| 359 | return false; | ||
| 360 | } | ||
| 361 | virtual bool TBZ(Imm<1> b5, Imm<5> b40, Imm<14> imm14, Reg Rt) { | ||
| 362 | return false; | ||
| 363 | } | ||
| 364 | virtual bool TBNZ(Imm<1> b5, Imm<5> b40, Imm<14> imm14, Reg Rt) { | ||
| 365 | return false; | ||
| 366 | } | ||
| 367 | |||
| 368 | // Loads and stores - Advanced SIMD Load/Store multiple structures | ||
| 369 | virtual bool STx_mult_1(bool Q, Imm<4> opcode, Imm<2> size, Reg Rn, Vec Vt) { | ||
| 370 | return false; | ||
| 371 | } | ||
| 372 | virtual bool STx_mult_2(bool Q, Reg Rm, Imm<4> opcode, Imm<2> size, Reg Rn, Vec Vt) { | ||
| 373 | return false; | ||
| 374 | } | ||
| 375 | virtual bool LDx_mult_1(bool Q, Imm<4> opcode, Imm<2> size, Reg Rn, Vec Vt) { | ||
| 376 | return false; | ||
| 377 | } | ||
| 378 | virtual bool LDx_mult_2(bool Q, Reg Rm, Imm<4> opcode, Imm<2> size, Reg Rn, Vec Vt) { | ||
| 379 | return false; | ||
| 380 | } | ||
| 381 | |||
| 382 | // Loads and stores - Advanced SIMD Load/Store single structures | ||
| 383 | virtual bool ST1_sngl_1(bool Q, Imm<2> upper_opcode, bool S, Imm<2> size, Reg Rn, Vec Vt) { | ||
| 384 | return false; | ||
| 385 | } | ||
| 386 | virtual bool ST1_sngl_2(bool Q, Reg Rm, Imm<2> upper_opcode, bool S, Imm<2> size, Reg Rn, | ||
| 387 | Vec Vt) { | ||
| 388 | return false; | ||
| 389 | } | ||
| 390 | virtual bool ST3_sngl_1(bool Q, Imm<2> upper_opcode, bool S, Imm<2> size, Reg Rn, Vec Vt) { | ||
| 391 | return false; | ||
| 392 | } | ||
| 393 | virtual bool ST3_sngl_2(bool Q, Reg Rm, Imm<2> upper_opcode, bool S, Imm<2> size, Reg Rn, | ||
| 394 | Vec Vt) { | ||
| 395 | return false; | ||
| 396 | } | ||
| 397 | virtual bool ST2_sngl_1(bool Q, Imm<2> upper_opcode, bool S, Imm<2> size, Reg Rn, Vec Vt) { | ||
| 398 | return false; | ||
| 399 | } | ||
| 400 | virtual bool ST2_sngl_2(bool Q, Reg Rm, Imm<2> upper_opcode, bool S, Imm<2> size, Reg Rn, | ||
| 401 | Vec Vt) { | ||
| 402 | return false; | ||
| 403 | } | ||
| 404 | virtual bool ST4_sngl_1(bool Q, Imm<2> upper_opcode, bool S, Imm<2> size, Reg Rn, Vec Vt) { | ||
| 405 | return false; | ||
| 406 | } | ||
| 407 | virtual bool ST4_sngl_2(bool Q, Reg Rm, Imm<2> upper_opcode, bool S, Imm<2> size, Reg Rn, | ||
| 408 | Vec Vt) { | ||
| 409 | return false; | ||
| 410 | } | ||
| 411 | virtual bool LD1_sngl_1(bool Q, Imm<2> upper_opcode, bool S, Imm<2> size, Reg Rn, Vec Vt) { | ||
| 412 | return false; | ||
| 413 | } | ||
| 414 | virtual bool LD1_sngl_2(bool Q, Reg Rm, Imm<2> upper_opcode, bool S, Imm<2> size, Reg Rn, | ||
| 415 | Vec Vt) { | ||
| 416 | return false; | ||
| 417 | } | ||
| 418 | virtual bool LD3_sngl_1(bool Q, Imm<2> upper_opcode, bool S, Imm<2> size, Reg Rn, Vec Vt) { | ||
| 419 | return false; | ||
| 420 | } | ||
| 421 | virtual bool LD3_sngl_2(bool Q, Reg Rm, Imm<2> upper_opcode, bool S, Imm<2> size, Reg Rn, | ||
| 422 | Vec Vt) { | ||
| 423 | return false; | ||
| 424 | } | ||
| 425 | virtual bool LD1R_1(bool Q, Imm<2> size, Reg Rn, Vec Vt) { | ||
| 426 | return false; | ||
| 427 | } | ||
| 428 | virtual bool LD1R_2(bool Q, Reg Rm, Imm<2> size, Reg Rn, Vec Vt) { | ||
| 429 | return false; | ||
| 430 | } | ||
| 431 | virtual bool LD3R_1(bool Q, Imm<2> size, Reg Rn, Vec Vt) { | ||
| 432 | return false; | ||
| 433 | } | ||
| 434 | virtual bool LD3R_2(bool Q, Reg Rm, Imm<2> size, Reg Rn, Vec Vt) { | ||
| 435 | return false; | ||
| 436 | } | ||
| 437 | virtual bool LD2_sngl_1(bool Q, Imm<2> upper_opcode, bool S, Imm<2> size, Reg Rn, Vec Vt) { | ||
| 438 | return false; | ||
| 439 | } | ||
| 440 | virtual bool LD2_sngl_2(bool Q, Reg Rm, Imm<2> upper_opcode, bool S, Imm<2> size, Reg Rn, | ||
| 441 | Vec Vt) { | ||
| 442 | return false; | ||
| 443 | } | ||
| 444 | virtual bool LD4_sngl_1(bool Q, Imm<2> upper_opcode, bool S, Imm<2> size, Reg Rn, Vec Vt) { | ||
| 445 | return false; | ||
| 446 | } | ||
| 447 | virtual bool LD4_sngl_2(bool Q, Reg Rm, Imm<2> upper_opcode, bool S, Imm<2> size, Reg Rn, | ||
| 448 | Vec Vt) { | ||
| 449 | return false; | ||
| 450 | } | ||
| 451 | virtual bool LD2R_1(bool Q, Imm<2> size, Reg Rn, Vec Vt) { | ||
| 452 | return false; | ||
| 453 | } | ||
| 454 | virtual bool LD2R_2(bool Q, Reg Rm, Imm<2> size, Reg Rn, Vec Vt) { | ||
| 455 | return false; | ||
| 456 | } | ||
| 457 | virtual bool LD4R_1(bool Q, Imm<2> size, Reg Rn, Vec Vt) { | ||
| 458 | return false; | ||
| 459 | } | ||
| 460 | virtual bool LD4R_2(bool Q, Reg Rm, Imm<2> size, Reg Rn, Vec Vt) { | ||
| 461 | return false; | ||
| 462 | } | ||
| 463 | |||
| 464 | // Loads and stores - Load/Store Exclusive | ||
| 465 | virtual bool STXR(Imm<2> size, Reg Rs, Reg Rn, Reg Rt) { | ||
| 466 | return false; | ||
| 467 | } | ||
| 468 | virtual bool STLXR(Imm<2> size, Reg Rs, Reg Rn, Reg Rt) { | ||
| 469 | return false; | ||
| 470 | } | ||
| 471 | virtual bool STXP(Imm<1> size, Reg Rs, Reg Rt2, Reg Rn, Reg Rt) { | ||
| 472 | return false; | ||
| 473 | } | ||
| 474 | virtual bool STLXP(Imm<1> size, Reg Rs, Reg Rt2, Reg Rn, Reg Rt) { | ||
| 475 | return false; | ||
| 476 | } | ||
| 477 | virtual bool LDXR(Imm<2> size, Reg Rn, Reg Rt) { | ||
| 478 | return false; | ||
| 479 | } | ||
| 480 | virtual bool LDAXR(Imm<2> size, Reg Rn, Reg Rt) { | ||
| 481 | return false; | ||
| 482 | } | ||
| 483 | virtual bool LDXP(Imm<1> size, Reg Rt2, Reg Rn, Reg Rt) { | ||
| 484 | return false; | ||
| 485 | } | ||
| 486 | virtual bool LDAXP(Imm<1> size, Reg Rt2, Reg Rn, Reg Rt) { | ||
| 487 | return false; | ||
| 488 | } | ||
| 489 | virtual bool STLLR(Imm<2> size, Reg Rn, Reg Rt) { | ||
| 490 | return false; | ||
| 491 | } | ||
| 492 | virtual bool STLR(Imm<2> size, Reg Rn, Reg Rt) { | ||
| 493 | return false; | ||
| 494 | } | ||
| 495 | virtual bool LDLAR(Imm<2> size, Reg Rn, Reg Rt) { | ||
| 496 | return false; | ||
| 497 | } | ||
| 498 | virtual bool LDAR(Imm<2> size, Reg Rn, Reg Rt) { | ||
| 499 | return false; | ||
| 500 | } | ||
| 501 | virtual bool CASP(bool sz, bool L, Reg Rs, bool o0, Reg Rn, Reg Rt) { | ||
| 502 | return false; | ||
| 503 | } | ||
| 504 | virtual bool CASB(bool L, Reg Rs, bool o0, Reg Rn, Reg Rt) { | ||
| 505 | return false; | ||
| 506 | } | ||
| 507 | virtual bool CASH(bool L, Reg Rs, bool o0, Reg Rn, Reg Rt) { | ||
| 508 | return false; | ||
| 509 | } | ||
| 510 | virtual bool CAS(bool sz, bool L, Reg Rs, bool o0, Reg Rn, Reg Rt) { | ||
| 511 | return false; | ||
| 512 | } | ||
| 513 | |||
| 514 | // Loads and stores - Load register (literal) | ||
| 515 | virtual bool LDR_lit_gen(bool opc_0, Imm<19> imm19, Reg Rt) { | ||
| 516 | return false; | ||
| 517 | } | ||
| 518 | virtual bool LDR_lit_fpsimd(Imm<2> opc, Imm<19> imm19, Vec Vt) { | ||
| 519 | return false; | ||
| 520 | } | ||
| 521 | virtual bool LDRSW_lit(Imm<19> imm19, Reg Rt) { | ||
| 522 | return false; | ||
| 523 | } | ||
| 524 | virtual bool PRFM_lit(Imm<19> imm19, Imm<5> prfop) { | ||
| 525 | return false; | ||
| 526 | } | ||
| 527 | |||
| 528 | // Loads and stores - Load/Store no-allocate pair | ||
| 529 | virtual bool STNP_LDNP_gen(Imm<1> upper_opc, Imm<1> L, Imm<7> imm7, Reg Rt2, Reg Rn, Reg Rt) { | ||
| 530 | return false; | ||
| 531 | } | ||
| 532 | virtual bool STNP_LDNP_fpsimd(Imm<2> opc, Imm<1> L, Imm<7> imm7, Vec Vt2, Reg Rn, Vec Vt) { | ||
| 533 | return false; | ||
| 534 | } | ||
| 535 | |||
| 536 | // Loads and stores - Load/Store register pair | ||
| 537 | virtual bool STP_LDP_gen(Imm<2> opc, bool not_postindex, bool wback, Imm<1> L, Imm<7> imm7, | ||
| 538 | Reg Rt2, Reg Rn, Reg Rt) { | ||
| 539 | return false; | ||
| 540 | } | ||
| 541 | virtual bool STP_LDP_fpsimd(Imm<2> opc, bool not_postindex, bool wback, Imm<1> L, Imm<7> imm7, | ||
| 542 | Vec Vt2, Reg Rn, Vec Vt) { | ||
| 543 | return false; | ||
| 544 | } | ||
| 545 | virtual bool STGP_1(Imm<7> offset_imm, Reg Rt2, Reg Rn, Reg Rt) { | ||
| 546 | return false; | ||
| 547 | } | ||
| 548 | virtual bool STGP_2(Imm<7> offset_imm, Reg Rt2, Reg Rn, Reg Rt) { | ||
| 549 | return false; | ||
| 550 | } | ||
| 551 | virtual bool STGP_3(Imm<7> offset_imm, Reg Rt2, Reg Rn, Reg Rt) { | ||
| 552 | return false; | ||
| 553 | } | ||
| 554 | |||
| 555 | // Loads and stores - Load/Store register (immediate) | ||
| 556 | virtual bool STRx_LDRx_imm_1(Imm<2> size, Imm<2> opc, Imm<9> imm9, bool not_postindex, Reg Rn, | ||
| 557 | Reg Rt) { | ||
| 558 | return false; | ||
| 559 | } | ||
| 560 | virtual bool STRx_LDRx_imm_2(Imm<2> size, Imm<2> opc, Imm<12> imm12, Reg Rn, Reg Rt) { | ||
| 561 | return false; | ||
| 562 | } | ||
| 563 | virtual bool STURx_LDURx(Imm<2> size, Imm<2> opc, Imm<9> imm9, Reg Rn, Reg Rt) { | ||
| 564 | return false; | ||
| 565 | } | ||
| 566 | virtual bool PRFM_imm(Imm<12> imm12, Reg Rn, Reg Rt) { | ||
| 567 | return false; | ||
| 568 | } | ||
| 569 | virtual bool PRFM_unscaled_imm(Imm<9> imm9, Reg Rn, Reg Rt) { | ||
| 570 | return false; | ||
| 571 | } | ||
| 572 | virtual bool STR_imm_fpsimd_1(Imm<2> size, Imm<1> opc_1, Imm<9> imm9, bool not_postindex, | ||
| 573 | Reg Rn, Vec Vt) { | ||
| 574 | return false; | ||
| 575 | } | ||
| 576 | virtual bool STR_imm_fpsimd_2(Imm<2> size, Imm<1> opc_1, Imm<12> imm12, Reg Rn, Vec Vt) { | ||
| 577 | return false; | ||
| 578 | } | ||
| 579 | virtual bool LDR_imm_fpsimd_1(Imm<2> size, Imm<1> opc_1, Imm<9> imm9, bool not_postindex, | ||
| 580 | Reg Rn, Vec Vt) { | ||
| 581 | return false; | ||
| 582 | } | ||
| 583 | virtual bool LDR_imm_fpsimd_2(Imm<2> size, Imm<1> opc_1, Imm<12> imm12, Reg Rn, Vec Vt) { | ||
| 584 | return false; | ||
| 585 | } | ||
| 586 | virtual bool STUR_fpsimd(Imm<2> size, Imm<1> opc_1, Imm<9> imm9, Reg Rn, Vec Vt) { | ||
| 587 | return false; | ||
| 588 | } | ||
| 589 | virtual bool LDUR_fpsimd(Imm<2> size, Imm<1> opc_1, Imm<9> imm9, Reg Rn, Vec Vt) { | ||
| 590 | return false; | ||
| 591 | } | ||
| 592 | |||
| 593 | // Loads and stores - Load/Store register (unprivileged) | ||
| 594 | virtual bool STTRB(Imm<9> imm9, Reg Rn, Reg Rt) { | ||
| 595 | return false; | ||
| 596 | } | ||
| 597 | virtual bool LDTRB(Imm<9> imm9, Reg Rn, Reg Rt) { | ||
| 598 | return false; | ||
| 599 | } | ||
| 600 | virtual bool LDTRSB(Imm<2> opc, Imm<9> imm9, Reg Rn, Reg Rt) { | ||
| 601 | return false; | ||
| 602 | } | ||
| 603 | virtual bool STTRH(Imm<9> imm9, Reg Rn, Reg Rt) { | ||
| 604 | return false; | ||
| 605 | } | ||
| 606 | virtual bool LDTRH(Imm<9> imm9, Reg Rn, Reg Rt) { | ||
| 607 | return false; | ||
| 608 | } | ||
| 609 | virtual bool LDTRSH(Imm<2> opc, Imm<9> imm9, Reg Rn, Reg Rt) { | ||
| 610 | return false; | ||
| 611 | } | ||
| 612 | virtual bool STTR(Imm<2> size, Imm<9> imm9, Reg Rn, Reg Rt) { | ||
| 613 | return false; | ||
| 614 | } | ||
| 615 | virtual bool LDTR(Imm<2> size, Imm<9> imm9, Reg Rn, Reg Rt) { | ||
| 616 | return false; | ||
| 617 | } | ||
| 618 | virtual bool LDTRSW(Imm<9> imm9, Reg Rn, Reg Rt) { | ||
| 619 | return false; | ||
| 620 | } | ||
| 621 | |||
| 622 | // Loads and stores - Atomic memory options | ||
| 623 | virtual bool LDADDB(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 624 | return false; | ||
| 625 | } | ||
| 626 | virtual bool LDCLRB(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 627 | return false; | ||
| 628 | } | ||
| 629 | virtual bool LDEORB(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 630 | return false; | ||
| 631 | } | ||
| 632 | virtual bool LDSETB(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 633 | return false; | ||
| 634 | } | ||
| 635 | virtual bool LDSMAXB(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 636 | return false; | ||
| 637 | } | ||
| 638 | virtual bool LDSMINB(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 639 | return false; | ||
| 640 | } | ||
| 641 | virtual bool LDUMAXB(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 642 | return false; | ||
| 643 | } | ||
| 644 | virtual bool LDUMINB(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 645 | return false; | ||
| 646 | } | ||
| 647 | virtual bool SWPB(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 648 | return false; | ||
| 649 | } | ||
| 650 | virtual bool LDAPRB(Reg Rn, Reg Rt) { | ||
| 651 | return false; | ||
| 652 | } | ||
| 653 | virtual bool LDADDH(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 654 | return false; | ||
| 655 | } | ||
| 656 | virtual bool LDCLRH(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 657 | return false; | ||
| 658 | } | ||
| 659 | virtual bool LDEORH(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 660 | return false; | ||
| 661 | } | ||
| 662 | virtual bool LDSETH(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 663 | return false; | ||
| 664 | } | ||
| 665 | virtual bool LDSMAXH(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 666 | return false; | ||
| 667 | } | ||
| 668 | virtual bool LDSMINH(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 669 | return false; | ||
| 670 | } | ||
| 671 | virtual bool LDUMAXH(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 672 | return false; | ||
| 673 | } | ||
| 674 | virtual bool LDUMINH(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 675 | return false; | ||
| 676 | } | ||
| 677 | virtual bool SWPH(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 678 | return false; | ||
| 679 | } | ||
| 680 | virtual bool LDAPRH(Reg Rn, Reg Rt) { | ||
| 681 | return false; | ||
| 682 | } | ||
| 683 | virtual bool LDADD(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 684 | return false; | ||
| 685 | } | ||
| 686 | virtual bool LDCLR(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 687 | return false; | ||
| 688 | } | ||
| 689 | virtual bool LDEOR(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 690 | return false; | ||
| 691 | } | ||
| 692 | virtual bool LDSET(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 693 | return false; | ||
| 694 | } | ||
| 695 | virtual bool LDSMAX(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 696 | return false; | ||
| 697 | } | ||
| 698 | virtual bool LDSMIN(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 699 | return false; | ||
| 700 | } | ||
| 701 | virtual bool LDUMAX(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 702 | return false; | ||
| 703 | } | ||
| 704 | virtual bool LDUMIN(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 705 | return false; | ||
| 706 | } | ||
| 707 | virtual bool SWP(bool A, bool R, Reg Rs, Reg Rn, Reg Rt) { | ||
| 708 | return false; | ||
| 709 | } | ||
| 710 | virtual bool LDAPR(Reg Rn, Reg Rt) { | ||
| 711 | return false; | ||
| 712 | } | ||
| 713 | |||
| 714 | // Loads and stores - Load/Store register (register offset) | ||
| 715 | virtual bool STRx_reg(Imm<2> size, Imm<1> opc_1, Reg Rm, Imm<3> option, bool S, Reg Rn, | ||
| 716 | Reg Rt) { | ||
| 717 | return false; | ||
| 718 | } | ||
| 719 | virtual bool LDRx_reg(Imm<2> size, Imm<1> opc_1, Reg Rm, Imm<3> option, bool S, Reg Rn, | ||
| 720 | Reg Rt) { | ||
| 721 | return false; | ||
| 722 | } | ||
| 723 | virtual bool STR_reg_fpsimd(Imm<2> size, Imm<1> opc_1, Reg Rm, Imm<3> option, bool S, Reg Rn, | ||
| 724 | Vec Vt) { | ||
| 725 | return false; | ||
| 726 | } | ||
| 727 | virtual bool LDR_reg_fpsimd(Imm<2> size, Imm<1> opc_1, Reg Rm, Imm<3> option, bool S, Reg Rn, | ||
| 728 | Vec Vt) { | ||
| 729 | return false; | ||
| 730 | } | ||
| 731 | |||
| 732 | // Loads and stores - Load/Store memory tags | ||
| 733 | virtual bool STG_1(Imm<9> imm9, Reg Rn) { | ||
| 734 | return false; | ||
| 735 | } | ||
| 736 | virtual bool STG_2(Imm<9> imm9, Reg Rn) { | ||
| 737 | return false; | ||
| 738 | } | ||
| 739 | virtual bool STG_3(Imm<9> imm9, Reg Rn) { | ||
| 740 | return false; | ||
| 741 | } | ||
| 742 | virtual bool LDG(Imm<9> offset_imm, Reg Rn, Reg Rt) { | ||
| 743 | return false; | ||
| 744 | } | ||
| 745 | virtual bool STZG_1(Imm<9> offset_imm, Reg Rn) { | ||
| 746 | return false; | ||
| 747 | } | ||
| 748 | virtual bool STZG_2(Imm<9> offset_imm, Reg Rn) { | ||
| 749 | return false; | ||
| 750 | } | ||
| 751 | virtual bool STZG_3(Imm<9> offset_imm, Reg Rn) { | ||
| 752 | return false; | ||
| 753 | } | ||
| 754 | virtual bool ST2G_1(Imm<9> offset_imm, Reg Rn) { | ||
| 755 | return false; | ||
| 756 | } | ||
| 757 | virtual bool ST2G_2(Imm<9> offset_imm, Reg Rn) { | ||
| 758 | return false; | ||
| 759 | } | ||
| 760 | virtual bool ST2G_3(Imm<9> offset_imm, Reg Rn) { | ||
| 761 | return false; | ||
| 762 | } | ||
| 763 | virtual bool STGV(Reg Rn, Reg Rt) { | ||
| 764 | return false; | ||
| 765 | } | ||
| 766 | virtual bool STZ2G_1(Imm<9> offset_imm, Reg Rn) { | ||
| 767 | return false; | ||
| 768 | } | ||
| 769 | virtual bool STZ2G_2(Imm<9> offset_imm, Reg Rn) { | ||
| 770 | return false; | ||
| 771 | } | ||
| 772 | virtual bool STZ2G_3(Imm<9> offset_imm, Reg Rn) { | ||
| 773 | return false; | ||
| 774 | } | ||
| 775 | virtual bool LDGV(Reg Rn, Reg Rt) { | ||
| 776 | return false; | ||
| 777 | } | ||
| 778 | |||
| 779 | // Loads and stores - Load/Store register (pointer authentication) | ||
| 780 | virtual bool LDRA(bool M, bool S, Imm<9> imm9, bool W, Reg Rn, Reg Rt) { | ||
| 781 | return false; | ||
| 782 | } | ||
| 783 | |||
| 784 | // Data Processing - Register - 2 source | ||
| 785 | virtual bool UDIV(bool sf, Reg Rm, Reg Rn, Reg Rd) { | ||
| 786 | return false; | ||
| 787 | } | ||
| 788 | virtual bool SDIV(bool sf, Reg Rm, Reg Rn, Reg Rd) { | ||
| 789 | return false; | ||
| 790 | } | ||
| 791 | virtual bool LSLV(bool sf, Reg Rm, Reg Rn, Reg Rd) { | ||
| 792 | return false; | ||
| 793 | } | ||
| 794 | virtual bool LSRV(bool sf, Reg Rm, Reg Rn, Reg Rd) { | ||
| 795 | return false; | ||
| 796 | } | ||
| 797 | virtual bool ASRV(bool sf, Reg Rm, Reg Rn, Reg Rd) { | ||
| 798 | return false; | ||
| 799 | } | ||
| 800 | virtual bool RORV(bool sf, Reg Rm, Reg Rn, Reg Rd) { | ||
| 801 | return false; | ||
| 802 | } | ||
| 803 | virtual bool CRC32(bool sf, Reg Rm, Imm<2> sz, Reg Rn, Reg Rd) { | ||
| 804 | return false; | ||
| 805 | } | ||
| 806 | virtual bool CRC32C(bool sf, Reg Rm, Imm<2> sz, Reg Rn, Reg Rd) { | ||
| 807 | return false; | ||
| 808 | } | ||
| 809 | virtual bool PACGA(Reg Rm, Reg Rn, Reg Rd) { | ||
| 810 | return false; | ||
| 811 | } | ||
| 812 | virtual bool SUBP(Reg Rm, Reg Rn, Reg Rd) { | ||
| 813 | return false; | ||
| 814 | } | ||
| 815 | virtual bool IRG(Reg Rm, Reg Rn, Reg Rd) { | ||
| 816 | return false; | ||
| 817 | } | ||
| 818 | virtual bool GMI(Reg Rm, Reg Rn, Reg Rd) { | ||
| 819 | return false; | ||
| 820 | } | ||
| 821 | virtual bool SUBPS(Reg Rm, Reg Rn, Reg Rd) { | ||
| 822 | return false; | ||
| 823 | } | ||
| 824 | |||
| 825 | // Data Processing - Register - 1 source | ||
| 826 | virtual bool RBIT_int(bool sf, Reg Rn, Reg Rd) { | ||
| 827 | return false; | ||
| 828 | } | ||
| 829 | virtual bool REV16_int(bool sf, Reg Rn, Reg Rd) { | ||
| 830 | return false; | ||
| 831 | } | ||
| 832 | virtual bool REV(bool sf, bool opc_0, Reg Rn, Reg Rd) { | ||
| 833 | return false; | ||
| 834 | } | ||
| 835 | virtual bool CLZ_int(bool sf, Reg Rn, Reg Rd) { | ||
| 836 | return false; | ||
| 837 | } | ||
| 838 | virtual bool CLS_int(bool sf, Reg Rn, Reg Rd) { | ||
| 839 | return false; | ||
| 840 | } | ||
| 841 | virtual bool REV32_int(Reg Rn, Reg Rd) { | ||
| 842 | return false; | ||
| 843 | } | ||
| 844 | virtual bool PACDA(bool Z, Reg Rn, Reg Rd) { | ||
| 845 | return false; | ||
| 846 | } | ||
| 847 | virtual bool PACDB(bool Z, Reg Rn, Reg Rd) { | ||
| 848 | return false; | ||
| 849 | } | ||
| 850 | virtual bool AUTDA(bool Z, Reg Rn, Reg Rd) { | ||
| 851 | return false; | ||
| 852 | } | ||
| 853 | virtual bool AUTDB(bool Z, Reg Rn, Reg Rd) { | ||
| 854 | return false; | ||
| 855 | } | ||
| 856 | |||
| 857 | // Data Processing - Register - Logical (shifted register) | ||
| 858 | virtual bool AND_shift(bool sf, Imm<2> shift, Reg Rm, Imm<6> imm6, Reg Rn, Reg Rd) { | ||
| 859 | return false; | ||
| 860 | } | ||
| 861 | virtual bool BIC_shift(bool sf, Imm<2> shift, Reg Rm, Imm<6> imm6, Reg Rn, Reg Rd) { | ||
| 862 | return false; | ||
| 863 | } | ||
| 864 | virtual bool ORR_shift(bool sf, Imm<2> shift, Reg Rm, Imm<6> imm6, Reg Rn, Reg Rd) { | ||
| 865 | return false; | ||
| 866 | } | ||
| 867 | virtual bool ORN_shift(bool sf, Imm<2> shift, Reg Rm, Imm<6> imm6, Reg Rn, Reg Rd) { | ||
| 868 | return false; | ||
| 869 | } | ||
| 870 | virtual bool EOR_shift(bool sf, Imm<2> shift, Reg Rm, Imm<6> imm6, Reg Rn, Reg Rd) { | ||
| 871 | return false; | ||
| 872 | } | ||
| 873 | virtual bool EON(bool sf, Imm<2> shift, Reg Rm, Imm<6> imm6, Reg Rn, Reg Rd) { | ||
| 874 | return false; | ||
| 875 | } | ||
| 876 | virtual bool ANDS_shift(bool sf, Imm<2> shift, Reg Rm, Imm<6> imm6, Reg Rn, Reg Rd) { | ||
| 877 | return false; | ||
| 878 | } | ||
| 879 | virtual bool BICS(bool sf, Imm<2> shift, Reg Rm, Imm<6> imm6, Reg Rn, Reg Rd) { | ||
| 880 | return false; | ||
| 881 | } | ||
| 882 | |||
| 883 | // Data Processing - Register - Add/Sub (shifted register) | ||
| 884 | virtual bool ADD_shift(bool sf, Imm<2> shift, Reg Rm, Imm<6> imm6, Reg Rn, Reg Rd) { | ||
| 885 | return false; | ||
| 886 | } | ||
| 887 | virtual bool ADDS_shift(bool sf, Imm<2> shift, Reg Rm, Imm<6> imm6, Reg Rn, Reg Rd) { | ||
| 888 | return false; | ||
| 889 | } | ||
| 890 | virtual bool SUB_shift(bool sf, Imm<2> shift, Reg Rm, Imm<6> imm6, Reg Rn, Reg Rd) { | ||
| 891 | return false; | ||
| 892 | } | ||
| 893 | virtual bool SUBS_shift(bool sf, Imm<2> shift, Reg Rm, Imm<6> imm6, Reg Rn, Reg Rd) { | ||
| 894 | return false; | ||
| 895 | } | ||
| 896 | |||
| 897 | // Data Processing - Register - Add/Sub (shifted register) | ||
| 898 | virtual bool ADD_ext(bool sf, Reg Rm, Imm<3> option, Imm<3> imm3, Reg Rn, Reg Rd) { | ||
| 899 | return false; | ||
| 900 | } | ||
| 901 | virtual bool ADDS_ext(bool sf, Reg Rm, Imm<3> option, Imm<3> imm3, Reg Rn, Reg Rd) { | ||
| 902 | return false; | ||
| 903 | } | ||
| 904 | virtual bool SUB_ext(bool sf, Reg Rm, Imm<3> option, Imm<3> imm3, Reg Rn, Reg Rd) { | ||
| 905 | return false; | ||
| 906 | } | ||
| 907 | virtual bool SUBS_ext(bool sf, Reg Rm, Imm<3> option, Imm<3> imm3, Reg Rn, Reg Rd) { | ||
| 908 | return false; | ||
| 909 | } | ||
| 910 | |||
| 911 | // Data Processing - Register - Add/Sub (with carry) | ||
| 912 | virtual bool ADC(bool sf, Reg Rm, Reg Rn, Reg Rd) { | ||
| 913 | return false; | ||
| 914 | } | ||
| 915 | virtual bool ADCS(bool sf, Reg Rm, Reg Rn, Reg Rd) { | ||
| 916 | return false; | ||
| 917 | } | ||
| 918 | virtual bool SBC(bool sf, Reg Rm, Reg Rn, Reg Rd) { | ||
| 919 | return false; | ||
| 920 | } | ||
| 921 | virtual bool SBCS(bool sf, Reg Rm, Reg Rn, Reg Rd) { | ||
| 922 | return false; | ||
| 923 | } | ||
| 924 | |||
| 925 | // Data Processing - Register - Conditional compare | ||
| 926 | virtual bool CCMN_reg(bool sf, Reg Rm, Cond cond, Reg Rn, Imm<4> nzcv) { | ||
| 927 | return false; | ||
| 928 | } | ||
| 929 | virtual bool CCMP_reg(bool sf, Reg Rm, Cond cond, Reg Rn, Imm<4> nzcv) { | ||
| 930 | return false; | ||
| 931 | } | ||
| 932 | virtual bool CCMN_imm(bool sf, Imm<5> imm5, Cond cond, Reg Rn, Imm<4> nzcv) { | ||
| 933 | return false; | ||
| 934 | } | ||
| 935 | virtual bool CCMP_imm(bool sf, Imm<5> imm5, Cond cond, Reg Rn, Imm<4> nzcv) { | ||
| 936 | return false; | ||
| 937 | } | ||
| 938 | |||
| 939 | // Data Processing - Register - Conditional select | ||
| 940 | virtual bool CSEL(bool sf, Reg Rm, Cond cond, Reg Rn, Reg Rd) { | ||
| 941 | return false; | ||
| 942 | } | ||
| 943 | virtual bool CSINC(bool sf, Reg Rm, Cond cond, Reg Rn, Reg Rd) { | ||
| 944 | return false; | ||
| 945 | } | ||
| 946 | virtual bool CSINV(bool sf, Reg Rm, Cond cond, Reg Rn, Reg Rd) { | ||
| 947 | return false; | ||
| 948 | } | ||
| 949 | virtual bool CSNEG(bool sf, Reg Rm, Cond cond, Reg Rn, Reg Rd) { | ||
| 950 | return false; | ||
| 951 | } | ||
| 952 | |||
| 953 | // Data Processing - Register - 3 source | ||
| 954 | virtual bool MADD(bool sf, Reg Rm, Reg Ra, Reg Rn, Reg Rd) { | ||
| 955 | return false; | ||
| 956 | } | ||
| 957 | virtual bool MSUB(bool sf, Reg Rm, Reg Ra, Reg Rn, Reg Rd) { | ||
| 958 | return false; | ||
| 959 | } | ||
| 960 | virtual bool SMADDL(Reg Rm, Reg Ra, Reg Rn, Reg Rd) { | ||
| 961 | return false; | ||
| 962 | } | ||
| 963 | virtual bool SMSUBL(Reg Rm, Reg Ra, Reg Rn, Reg Rd) { | ||
| 964 | return false; | ||
| 965 | } | ||
| 966 | virtual bool SMULH(Reg Rm, Reg Rn, Reg Rd) { | ||
| 967 | return false; | ||
| 968 | } | ||
| 969 | virtual bool UMADDL(Reg Rm, Reg Ra, Reg Rn, Reg Rd) { | ||
| 970 | return false; | ||
| 971 | } | ||
| 972 | virtual bool UMSUBL(Reg Rm, Reg Ra, Reg Rn, Reg Rd) { | ||
| 973 | return false; | ||
| 974 | } | ||
| 975 | virtual bool UMULH(Reg Rm, Reg Rn, Reg Rd) { | ||
| 976 | return false; | ||
| 977 | } | ||
| 978 | |||
| 979 | // Data Processing - FP and SIMD - AES | ||
| 980 | virtual bool AESE(Vec Vn, Vec Vd) { | ||
| 981 | return false; | ||
| 982 | } | ||
| 983 | virtual bool AESD(Vec Vn, Vec Vd) { | ||
| 984 | return false; | ||
| 985 | } | ||
| 986 | virtual bool AESMC(Vec Vn, Vec Vd) { | ||
| 987 | return false; | ||
| 988 | } | ||
| 989 | virtual bool AESIMC(Vec Vn, Vec Vd) { | ||
| 990 | return false; | ||
| 991 | } | ||
| 992 | |||
| 993 | // Data Processing - FP and SIMD - SHA | ||
| 994 | virtual bool SHA1C(Vec Vm, Vec Vn, Vec Vd) { | ||
| 995 | return false; | ||
| 996 | } | ||
| 997 | virtual bool SHA1P(Vec Vm, Vec Vn, Vec Vd) { | ||
| 998 | return false; | ||
| 999 | } | ||
| 1000 | virtual bool SHA1M(Vec Vm, Vec Vn, Vec Vd) { | ||
| 1001 | return false; | ||
| 1002 | } | ||
| 1003 | virtual bool SHA1SU0(Vec Vm, Vec Vn, Vec Vd) { | ||
| 1004 | return false; | ||
| 1005 | } | ||
| 1006 | virtual bool SHA256H(Vec Vm, Vec Vn, Vec Vd) { | ||
| 1007 | return false; | ||
| 1008 | } | ||
| 1009 | virtual bool SHA256H2(Vec Vm, Vec Vn, Vec Vd) { | ||
| 1010 | return false; | ||
| 1011 | } | ||
| 1012 | virtual bool SHA256SU1(Vec Vm, Vec Vn, Vec Vd) { | ||
| 1013 | return false; | ||
| 1014 | } | ||
| 1015 | virtual bool SHA1H(Vec Vn, Vec Vd) { | ||
| 1016 | return false; | ||
| 1017 | } | ||
| 1018 | virtual bool SHA1SU1(Vec Vn, Vec Vd) { | ||
| 1019 | return false; | ||
| 1020 | } | ||
| 1021 | virtual bool SHA256SU0(Vec Vn, Vec Vd) { | ||
| 1022 | return false; | ||
| 1023 | } | ||
| 1024 | |||
| 1025 | // Data Processing - FP and SIMD - Scalar copy | ||
| 1026 | virtual bool DUP_elt_1(Imm<5> imm5, Vec Vn, Vec Vd) { | ||
| 1027 | return false; | ||
| 1028 | } | ||
| 1029 | |||
| 1030 | // Data Processing - FP and SIMD - Scalar three | ||
| 1031 | virtual bool FMULX_vec_1(Vec Vm, Vec Vn, Vec Vd) { | ||
| 1032 | return false; | ||
| 1033 | } | ||
| 1034 | virtual bool FMULX_vec_2(bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1035 | return false; | ||
| 1036 | } | ||
| 1037 | virtual bool FCMEQ_reg_1(Vec Vm, Vec Vn, Vec Vd) { | ||
| 1038 | return false; | ||
| 1039 | } | ||
| 1040 | virtual bool FCMEQ_reg_2(bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1041 | return false; | ||
| 1042 | } | ||
| 1043 | virtual bool FRECPS_1(Vec Vm, Vec Vn, Vec Vd) { | ||
| 1044 | return false; | ||
| 1045 | } | ||
| 1046 | virtual bool FRECPS_2(bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1047 | return false; | ||
| 1048 | } | ||
| 1049 | virtual bool FRSQRTS_1(Vec Vm, Vec Vn, Vec Vd) { | ||
| 1050 | return false; | ||
| 1051 | } | ||
| 1052 | virtual bool FRSQRTS_2(bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1053 | return false; | ||
| 1054 | } | ||
| 1055 | virtual bool FCMGE_reg_1(Vec Vm, Vec Vn, Vec Vd) { | ||
| 1056 | return false; | ||
| 1057 | } | ||
| 1058 | virtual bool FCMGE_reg_2(bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1059 | return false; | ||
| 1060 | } | ||
| 1061 | virtual bool FACGE_1(Vec Vm, Vec Vn, Vec Vd) { | ||
| 1062 | return false; | ||
| 1063 | } | ||
| 1064 | virtual bool FACGE_2(bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1065 | return false; | ||
| 1066 | } | ||
| 1067 | virtual bool FABD_1(Vec Vm, Vec Vn, Vec Vd) { | ||
| 1068 | return false; | ||
| 1069 | } | ||
| 1070 | virtual bool FABD_2(bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1071 | return false; | ||
| 1072 | } | ||
| 1073 | virtual bool FCMGT_reg_1(Vec Vm, Vec Vn, Vec Vd) { | ||
| 1074 | return false; | ||
| 1075 | } | ||
| 1076 | virtual bool FCMGT_reg_2(bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1077 | return false; | ||
| 1078 | } | ||
| 1079 | virtual bool FACGT_1(Vec Vm, Vec Vn, Vec Vd) { | ||
| 1080 | return false; | ||
| 1081 | } | ||
| 1082 | virtual bool FACGT_2(bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1083 | return false; | ||
| 1084 | } | ||
| 1085 | |||
| 1086 | // Data Processing - FP and SIMD - Two register misc FP16 | ||
| 1087 | virtual bool FCVTNS_1(Vec Vn, Vec Vd) { | ||
| 1088 | return false; | ||
| 1089 | } | ||
| 1090 | virtual bool FCVTMS_1(Vec Vn, Vec Vd) { | ||
| 1091 | return false; | ||
| 1092 | } | ||
| 1093 | virtual bool FCVTAS_1(Vec Vn, Vec Vd) { | ||
| 1094 | return false; | ||
| 1095 | } | ||
| 1096 | virtual bool SCVTF_int_1(Vec Vn, Vec Vd) { | ||
| 1097 | return false; | ||
| 1098 | } | ||
| 1099 | virtual bool FCMGT_zero_1(Vec Vn, Vec Vd) { | ||
| 1100 | return false; | ||
| 1101 | } | ||
| 1102 | virtual bool FCMEQ_zero_1(Vec Vn, Vec Vd) { | ||
| 1103 | return false; | ||
| 1104 | } | ||
| 1105 | virtual bool FCMLT_1(Vec Vn, Vec Vd) { | ||
| 1106 | return false; | ||
| 1107 | } | ||
| 1108 | virtual bool FCVTPS_1(Vec Vn, Vec Vd) { | ||
| 1109 | return false; | ||
| 1110 | } | ||
| 1111 | virtual bool FCVTZS_int_1(Vec Vn, Vec Vd) { | ||
| 1112 | return false; | ||
| 1113 | } | ||
| 1114 | virtual bool FRECPE_1(Vec Vn, Vec Vd) { | ||
| 1115 | return false; | ||
| 1116 | } | ||
| 1117 | virtual bool FRECPX_1(Vec Vn, Vec Vd) { | ||
| 1118 | return false; | ||
| 1119 | } | ||
| 1120 | virtual bool FCVTNU_1(Vec Vn, Vec Vd) { | ||
| 1121 | return false; | ||
| 1122 | } | ||
| 1123 | virtual bool FCVTMU_1(Vec Vn, Vec Vd) { | ||
| 1124 | return false; | ||
| 1125 | } | ||
| 1126 | virtual bool FCVTAU_1(Vec Vn, Vec Vd) { | ||
| 1127 | return false; | ||
| 1128 | } | ||
| 1129 | virtual bool UCVTF_int_1(Vec Vn, Vec Vd) { | ||
| 1130 | return false; | ||
| 1131 | } | ||
| 1132 | virtual bool FCMGE_zero_1(Vec Vn, Vec Vd) { | ||
| 1133 | return false; | ||
| 1134 | } | ||
| 1135 | virtual bool FCMLE_1(Vec Vn, Vec Vd) { | ||
| 1136 | return false; | ||
| 1137 | } | ||
| 1138 | virtual bool FCVTPU_1(Vec Vn, Vec Vd) { | ||
| 1139 | return false; | ||
| 1140 | } | ||
| 1141 | virtual bool FCVTZU_int_1(Vec Vn, Vec Vd) { | ||
| 1142 | return false; | ||
| 1143 | } | ||
| 1144 | virtual bool FRSQRTE_1(Vec Vn, Vec Vd) { | ||
| 1145 | return false; | ||
| 1146 | } | ||
| 1147 | |||
| 1148 | // Data Processing - FP and SIMD - Two register misc | ||
| 1149 | virtual bool FCVTNS_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1150 | return false; | ||
| 1151 | } | ||
| 1152 | virtual bool FCVTMS_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1153 | return false; | ||
| 1154 | } | ||
| 1155 | virtual bool FCVTAS_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1156 | return false; | ||
| 1157 | } | ||
| 1158 | virtual bool SCVTF_int_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1159 | return false; | ||
| 1160 | } | ||
| 1161 | virtual bool FCMGT_zero_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1162 | return false; | ||
| 1163 | } | ||
| 1164 | virtual bool FCMEQ_zero_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1165 | return false; | ||
| 1166 | } | ||
| 1167 | virtual bool FCMLT_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1168 | return false; | ||
| 1169 | } | ||
| 1170 | virtual bool FCVTPS_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1171 | return false; | ||
| 1172 | } | ||
| 1173 | virtual bool FCVTZS_int_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1174 | return false; | ||
| 1175 | } | ||
| 1176 | virtual bool FRECPE_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1177 | return false; | ||
| 1178 | } | ||
| 1179 | virtual bool FRECPX_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1180 | return false; | ||
| 1181 | } | ||
| 1182 | virtual bool FCVTNU_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1183 | return false; | ||
| 1184 | } | ||
| 1185 | virtual bool FCVTMU_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1186 | return false; | ||
| 1187 | } | ||
| 1188 | virtual bool FCVTAU_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1189 | return false; | ||
| 1190 | } | ||
| 1191 | virtual bool UCVTF_int_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1192 | return false; | ||
| 1193 | } | ||
| 1194 | virtual bool FCMGE_zero_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1195 | return false; | ||
| 1196 | } | ||
| 1197 | virtual bool FCMLE_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1198 | return false; | ||
| 1199 | } | ||
| 1200 | virtual bool FCVTPU_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1201 | return false; | ||
| 1202 | } | ||
| 1203 | virtual bool FCVTZU_int_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1204 | return false; | ||
| 1205 | } | ||
| 1206 | virtual bool FRSQRTE_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1207 | return false; | ||
| 1208 | } | ||
| 1209 | |||
| 1210 | // Data Processing - FP and SIMD - Scalar two register misc FP16 | ||
| 1211 | virtual bool FCVTNS_3(bool Q, Vec Vn, Vec Vd) { | ||
| 1212 | return false; | ||
| 1213 | } | ||
| 1214 | virtual bool FCVTMS_3(bool Q, Vec Vn, Vec Vd) { | ||
| 1215 | return false; | ||
| 1216 | } | ||
| 1217 | virtual bool FCVTAS_3(bool Q, Vec Vn, Vec Vd) { | ||
| 1218 | return false; | ||
| 1219 | } | ||
| 1220 | virtual bool SCVTF_int_3(bool Q, Vec Vn, Vec Vd) { | ||
| 1221 | return false; | ||
| 1222 | } | ||
| 1223 | virtual bool FCMGT_zero_3(bool Q, Vec Vn, Vec Vd) { | ||
| 1224 | return false; | ||
| 1225 | } | ||
| 1226 | virtual bool FCMEQ_zero_3(bool Q, Vec Vn, Vec Vd) { | ||
| 1227 | return false; | ||
| 1228 | } | ||
| 1229 | virtual bool FCMLT_3(bool Q, Vec Vn, Vec Vd) { | ||
| 1230 | return false; | ||
| 1231 | } | ||
| 1232 | virtual bool FCVTPS_3(bool Q, Vec Vn, Vec Vd) { | ||
| 1233 | return false; | ||
| 1234 | } | ||
| 1235 | virtual bool FCVTZS_int_3(bool Q, Vec Vn, Vec Vd) { | ||
| 1236 | return false; | ||
| 1237 | } | ||
| 1238 | virtual bool FRECPE_3(bool Q, Vec Vn, Vec Vd) { | ||
| 1239 | return false; | ||
| 1240 | } | ||
| 1241 | virtual bool FCVTNU_3(bool Q, Vec Vn, Vec Vd) { | ||
| 1242 | return false; | ||
| 1243 | } | ||
| 1244 | virtual bool FCVTMU_3(bool Q, Vec Vn, Vec Vd) { | ||
| 1245 | return false; | ||
| 1246 | } | ||
| 1247 | virtual bool FCVTAU_3(bool Q, Vec Vn, Vec Vd) { | ||
| 1248 | return false; | ||
| 1249 | } | ||
| 1250 | virtual bool UCVTF_int_3(bool Q, Vec Vn, Vec Vd) { | ||
| 1251 | return false; | ||
| 1252 | } | ||
| 1253 | virtual bool FCMGE_zero_3(bool Q, Vec Vn, Vec Vd) { | ||
| 1254 | return false; | ||
| 1255 | } | ||
| 1256 | virtual bool FCMLE_3(bool Q, Vec Vn, Vec Vd) { | ||
| 1257 | return false; | ||
| 1258 | } | ||
| 1259 | virtual bool FCVTPU_3(bool Q, Vec Vn, Vec Vd) { | ||
| 1260 | return false; | ||
| 1261 | } | ||
| 1262 | virtual bool FCVTZU_int_3(bool Q, Vec Vn, Vec Vd) { | ||
| 1263 | return false; | ||
| 1264 | } | ||
| 1265 | virtual bool FRSQRTE_3(bool Q, Vec Vn, Vec Vd) { | ||
| 1266 | return false; | ||
| 1267 | } | ||
| 1268 | |||
| 1269 | // Data Processing - FP and SIMD - Scalar two register misc | ||
| 1270 | virtual bool FCVTNS_4(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1271 | return false; | ||
| 1272 | } | ||
| 1273 | virtual bool FCVTMS_4(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1274 | return false; | ||
| 1275 | } | ||
| 1276 | virtual bool FCVTAS_4(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1277 | return false; | ||
| 1278 | } | ||
| 1279 | virtual bool SCVTF_int_4(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1280 | return false; | ||
| 1281 | } | ||
| 1282 | virtual bool FCMGT_zero_4(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1283 | return false; | ||
| 1284 | } | ||
| 1285 | virtual bool FCMEQ_zero_4(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1286 | return false; | ||
| 1287 | } | ||
| 1288 | virtual bool FCMLT_4(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1289 | return false; | ||
| 1290 | } | ||
| 1291 | virtual bool FCVTPS_4(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1292 | return false; | ||
| 1293 | } | ||
| 1294 | virtual bool FCVTZS_int_4(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1295 | return false; | ||
| 1296 | } | ||
| 1297 | virtual bool FRECPE_4(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1298 | return false; | ||
| 1299 | } | ||
| 1300 | virtual bool FCVTNU_4(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1301 | return false; | ||
| 1302 | } | ||
| 1303 | virtual bool FCVTMU_4(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1304 | return false; | ||
| 1305 | } | ||
| 1306 | virtual bool FCVTAU_4(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1307 | return false; | ||
| 1308 | } | ||
| 1309 | virtual bool UCVTF_int_4(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1310 | return false; | ||
| 1311 | } | ||
| 1312 | virtual bool FCMGE_zero_4(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1313 | return false; | ||
| 1314 | } | ||
| 1315 | virtual bool FCMLE_4(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1316 | return false; | ||
| 1317 | } | ||
| 1318 | virtual bool FCVTPU_4(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1319 | return false; | ||
| 1320 | } | ||
| 1321 | virtual bool FCVTZU_int_4(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1322 | return false; | ||
| 1323 | } | ||
| 1324 | virtual bool FRSQRTE_4(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1325 | return false; | ||
| 1326 | } | ||
| 1327 | |||
| 1328 | // Data Processing - FP and SIMD - Scalar three same extra | ||
| 1329 | virtual bool SQRDMLAH_vec_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1330 | return false; | ||
| 1331 | } | ||
| 1332 | virtual bool SQRDMLAH_vec_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1333 | return false; | ||
| 1334 | } | ||
| 1335 | virtual bool SQRDMLSH_vec_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1336 | return false; | ||
| 1337 | } | ||
| 1338 | virtual bool SQRDMLSH_vec_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1339 | return false; | ||
| 1340 | } | ||
| 1341 | |||
| 1342 | // Data Processing - FP and SIMD - Scalar two-register misc | ||
| 1343 | virtual bool SUQADD_1(Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1344 | return false; | ||
| 1345 | } | ||
| 1346 | virtual bool SQABS_1(Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1347 | return false; | ||
| 1348 | } | ||
| 1349 | virtual bool CMGT_zero_1(Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1350 | return false; | ||
| 1351 | } | ||
| 1352 | virtual bool CMEQ_zero_1(Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1353 | return false; | ||
| 1354 | } | ||
| 1355 | virtual bool CMLT_1(Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1356 | return false; | ||
| 1357 | } | ||
| 1358 | virtual bool ABS_1(Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1359 | return false; | ||
| 1360 | } | ||
| 1361 | virtual bool SQXTN_1(Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1362 | return false; | ||
| 1363 | } | ||
| 1364 | virtual bool USQADD_1(Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1365 | return false; | ||
| 1366 | } | ||
| 1367 | virtual bool SQNEG_1(Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1368 | return false; | ||
| 1369 | } | ||
| 1370 | virtual bool CMGE_zero_1(Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1371 | return false; | ||
| 1372 | } | ||
| 1373 | virtual bool CMLE_1(Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1374 | return false; | ||
| 1375 | } | ||
| 1376 | virtual bool NEG_1(Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1377 | return false; | ||
| 1378 | } | ||
| 1379 | virtual bool SQXTUN_1(Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1380 | return false; | ||
| 1381 | } | ||
| 1382 | virtual bool UQXTN_1(Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1383 | return false; | ||
| 1384 | } | ||
| 1385 | virtual bool FCVTXN_1(bool sz, Vec Vn, Vec Vd) { | ||
| 1386 | return false; | ||
| 1387 | } | ||
| 1388 | |||
| 1389 | // Data Processing - FP and SIMD - SIMD Scalar pairwise | ||
| 1390 | virtual bool ADDP_pair(Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1391 | return false; | ||
| 1392 | } | ||
| 1393 | virtual bool FMAXNMP_pair_1(Vec Vn, Vec Vd) { | ||
| 1394 | return false; | ||
| 1395 | } | ||
| 1396 | virtual bool FMAXNMP_pair_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1397 | return false; | ||
| 1398 | } | ||
| 1399 | virtual bool FADDP_pair_1(Vec Vn, Vec Vd) { | ||
| 1400 | return false; | ||
| 1401 | } | ||
| 1402 | virtual bool FADDP_pair_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1403 | return false; | ||
| 1404 | } | ||
| 1405 | virtual bool FMAXP_pair_1(Vec Vn, Vec Vd) { | ||
| 1406 | return false; | ||
| 1407 | } | ||
| 1408 | virtual bool FMAXP_pair_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1409 | return false; | ||
| 1410 | } | ||
| 1411 | virtual bool FMINNMP_pair_1(Vec Vn, Vec Vd) { | ||
| 1412 | return false; | ||
| 1413 | } | ||
| 1414 | virtual bool FMINNMP_pair_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1415 | return false; | ||
| 1416 | } | ||
| 1417 | virtual bool FMINP_pair_1(Vec Vn, Vec Vd) { | ||
| 1418 | return false; | ||
| 1419 | } | ||
| 1420 | virtual bool FMINP_pair_2(bool sz, Vec Vn, Vec Vd) { | ||
| 1421 | return false; | ||
| 1422 | } | ||
| 1423 | |||
| 1424 | // Data Processing - FP and SIMD - SIMD Scalar three different | ||
| 1425 | virtual bool SQDMLAL_vec_1(Imm<2> size, Reg Rm, Reg Rn, Vec Vd) { | ||
| 1426 | return false; | ||
| 1427 | } | ||
| 1428 | virtual bool SQDMLSL_vec_1(Imm<2> size, Reg Rm, Reg Rn, Vec Vd) { | ||
| 1429 | return false; | ||
| 1430 | } | ||
| 1431 | virtual bool SQDMULL_vec_1(Imm<2> size, Reg Rm, Reg Rn, Vec Vd) { | ||
| 1432 | return false; | ||
| 1433 | } | ||
| 1434 | |||
| 1435 | // Data Processing - FP and SIMD - SIMD Scalar three same | ||
| 1436 | virtual bool SQADD_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1437 | return false; | ||
| 1438 | } | ||
| 1439 | virtual bool SQSUB_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1440 | return false; | ||
| 1441 | } | ||
| 1442 | virtual bool CMGT_reg_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1443 | return false; | ||
| 1444 | } | ||
| 1445 | virtual bool CMGE_reg_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1446 | return false; | ||
| 1447 | } | ||
| 1448 | virtual bool SSHL_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1449 | return false; | ||
| 1450 | } | ||
| 1451 | virtual bool SQSHL_reg_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1452 | return false; | ||
| 1453 | } | ||
| 1454 | virtual bool SRSHL_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1455 | return false; | ||
| 1456 | } | ||
| 1457 | virtual bool SQRSHL_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1458 | return false; | ||
| 1459 | } | ||
| 1460 | virtual bool ADD_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1461 | return false; | ||
| 1462 | } | ||
| 1463 | virtual bool CMTST_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1464 | return false; | ||
| 1465 | } | ||
| 1466 | virtual bool SQDMULH_vec_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1467 | return false; | ||
| 1468 | } | ||
| 1469 | virtual bool UQADD_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1470 | return false; | ||
| 1471 | } | ||
| 1472 | virtual bool UQSUB_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1473 | return false; | ||
| 1474 | } | ||
| 1475 | virtual bool CMHI_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1476 | return false; | ||
| 1477 | } | ||
| 1478 | virtual bool CMHS_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1479 | return false; | ||
| 1480 | } | ||
| 1481 | virtual bool USHL_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1482 | return false; | ||
| 1483 | } | ||
| 1484 | virtual bool UQSHL_reg_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1485 | return false; | ||
| 1486 | } | ||
| 1487 | virtual bool URSHL_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1488 | return false; | ||
| 1489 | } | ||
| 1490 | virtual bool UQRSHL_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1491 | return false; | ||
| 1492 | } | ||
| 1493 | virtual bool SUB_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1494 | return false; | ||
| 1495 | } | ||
| 1496 | virtual bool CMEQ_reg_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1497 | return false; | ||
| 1498 | } | ||
| 1499 | virtual bool SQRDMULH_vec_1(Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1500 | return false; | ||
| 1501 | } | ||
| 1502 | |||
| 1503 | // Data Processing - FP and SIMD - SIMD Scalar shift by immediate | ||
| 1504 | virtual bool SSHR_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 1505 | return false; | ||
| 1506 | } | ||
| 1507 | virtual bool SSRA_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 1508 | return false; | ||
| 1509 | } | ||
| 1510 | virtual bool SRSHR_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 1511 | return false; | ||
| 1512 | } | ||
| 1513 | virtual bool SRSRA_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 1514 | return false; | ||
| 1515 | } | ||
| 1516 | virtual bool SHL_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 1517 | return false; | ||
| 1518 | } | ||
| 1519 | virtual bool SQSHL_imm_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 1520 | return false; | ||
| 1521 | } | ||
| 1522 | virtual bool SQSHRN_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 1523 | return false; | ||
| 1524 | } | ||
| 1525 | virtual bool SQRSHRN_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 1526 | return false; | ||
| 1527 | } | ||
| 1528 | virtual bool SCVTF_fix_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 1529 | return false; | ||
| 1530 | } | ||
| 1531 | virtual bool FCVTZS_fix_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 1532 | return false; | ||
| 1533 | } | ||
| 1534 | virtual bool USHR_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 1535 | return false; | ||
| 1536 | } | ||
| 1537 | virtual bool USRA_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 1538 | return false; | ||
| 1539 | } | ||
| 1540 | virtual bool URSHR_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 1541 | return false; | ||
| 1542 | } | ||
| 1543 | virtual bool URSRA_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 1544 | return false; | ||
| 1545 | } | ||
| 1546 | virtual bool SRI_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 1547 | return false; | ||
| 1548 | } | ||
| 1549 | virtual bool SLI_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 1550 | return false; | ||
| 1551 | } | ||
| 1552 | virtual bool SQSHLU_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 1553 | return false; | ||
| 1554 | } | ||
| 1555 | virtual bool UQSHL_imm_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 1556 | return false; | ||
| 1557 | } | ||
| 1558 | virtual bool SQSHRUN_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 1559 | return false; | ||
| 1560 | } | ||
| 1561 | virtual bool SQRSHRUN_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 1562 | return false; | ||
| 1563 | } | ||
| 1564 | virtual bool UQSHRN_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 1565 | return false; | ||
| 1566 | } | ||
| 1567 | virtual bool UQRSHRN_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 1568 | return false; | ||
| 1569 | } | ||
| 1570 | virtual bool UCVTF_fix_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 1571 | return false; | ||
| 1572 | } | ||
| 1573 | virtual bool FCVTZU_fix_1(Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 1574 | return false; | ||
| 1575 | } | ||
| 1576 | |||
| 1577 | // Data Processing - FP and SIMD - SIMD Scalar x indexed element | ||
| 1578 | virtual bool SQDMLAL_elt_1(Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 1579 | Vec Vd) { | ||
| 1580 | return false; | ||
| 1581 | } | ||
| 1582 | virtual bool SQDMLSL_elt_1(Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 1583 | Vec Vd) { | ||
| 1584 | return false; | ||
| 1585 | } | ||
| 1586 | virtual bool SQDMULL_elt_1(Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 1587 | Vec Vd) { | ||
| 1588 | return false; | ||
| 1589 | } | ||
| 1590 | virtual bool SQDMULH_elt_1(Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 1591 | Vec Vd) { | ||
| 1592 | return false; | ||
| 1593 | } | ||
| 1594 | virtual bool SQRDMULH_elt_1(Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 1595 | Vec Vd) { | ||
| 1596 | return false; | ||
| 1597 | } | ||
| 1598 | virtual bool FMLA_elt_1(Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, Vec Vd) { | ||
| 1599 | return false; | ||
| 1600 | } | ||
| 1601 | virtual bool FMLA_elt_2(bool sz, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, Vec Vd) { | ||
| 1602 | return false; | ||
| 1603 | } | ||
| 1604 | virtual bool FMLS_elt_1(Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, Vec Vd) { | ||
| 1605 | return false; | ||
| 1606 | } | ||
| 1607 | virtual bool FMLS_elt_2(bool sz, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, Vec Vd) { | ||
| 1608 | return false; | ||
| 1609 | } | ||
| 1610 | virtual bool FMUL_elt_1(Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, Vec Vd) { | ||
| 1611 | return false; | ||
| 1612 | } | ||
| 1613 | virtual bool FMUL_elt_2(bool sz, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, Vec Vd) { | ||
| 1614 | return false; | ||
| 1615 | } | ||
| 1616 | virtual bool SQRDMLAH_elt_1(Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 1617 | Vec Vd) { | ||
| 1618 | return false; | ||
| 1619 | } | ||
| 1620 | virtual bool SQRDMLSH_elt_1(Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 1621 | Vec Vd) { | ||
| 1622 | return false; | ||
| 1623 | } | ||
| 1624 | virtual bool FMULX_elt_1(Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, Vec Vd) { | ||
| 1625 | return false; | ||
| 1626 | } | ||
| 1627 | virtual bool FMULX_elt_2(bool sz, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, Vec Vd) { | ||
| 1628 | return false; | ||
| 1629 | } | ||
| 1630 | |||
| 1631 | // Data Processing - FP and SIMD - SIMD Table Lookup | ||
| 1632 | virtual bool TBL(bool Q, Vec Vm, Imm<2> len, size_t Vn, Vec Vd) { | ||
| 1633 | return false; | ||
| 1634 | } | ||
| 1635 | virtual bool TBX(bool Q, Vec Vm, Imm<2> len, size_t Vn, Vec Vd) { | ||
| 1636 | return false; | ||
| 1637 | } | ||
| 1638 | |||
| 1639 | // Data Processing - FP and SIMD - SIMD Permute | ||
| 1640 | virtual bool UZP1(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1641 | return false; | ||
| 1642 | } | ||
| 1643 | virtual bool TRN1(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1644 | return false; | ||
| 1645 | } | ||
| 1646 | virtual bool ZIP1(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1647 | return false; | ||
| 1648 | } | ||
| 1649 | virtual bool UZP2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1650 | return false; | ||
| 1651 | } | ||
| 1652 | virtual bool TRN2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1653 | return false; | ||
| 1654 | } | ||
| 1655 | virtual bool ZIP2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1656 | return false; | ||
| 1657 | } | ||
| 1658 | |||
| 1659 | // Data Processing - FP and SIMD - SIMD Extract | ||
| 1660 | virtual bool EXT(bool Q, Vec Vm, Imm<4> imm4, Vec Vn, Vec Vd) { | ||
| 1661 | return false; | ||
| 1662 | } | ||
| 1663 | |||
| 1664 | // Data Processing - FP and SIMD - SIMD Copy | ||
| 1665 | virtual bool DUP_elt_2(bool Q, Imm<5> imm5, Vec Vn, Vec Vd) { | ||
| 1666 | return false; | ||
| 1667 | } | ||
| 1668 | virtual bool DUP_gen(bool Q, Imm<5> imm5, Reg Rn, Vec Vd) { | ||
| 1669 | return false; | ||
| 1670 | } | ||
| 1671 | virtual bool SMOV(bool Q, Imm<5> imm5, Vec Vn, Reg Rd) { | ||
| 1672 | return false; | ||
| 1673 | } | ||
| 1674 | virtual bool UMOV(bool Q, Imm<5> imm5, Vec Vn, Reg Rd) { | ||
| 1675 | return false; | ||
| 1676 | } | ||
| 1677 | virtual bool INS_gen(Imm<5> imm5, Reg Rn, Vec Vd) { | ||
| 1678 | return false; | ||
| 1679 | } | ||
| 1680 | virtual bool INS_elt(Imm<5> imm5, Imm<4> imm4, Vec Vn, Vec Vd) { | ||
| 1681 | return false; | ||
| 1682 | } | ||
| 1683 | |||
| 1684 | // Data Processing - FP and SIMD - SIMD Three same | ||
| 1685 | virtual bool FMULX_vec_3(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1686 | return false; | ||
| 1687 | } | ||
| 1688 | virtual bool FCMEQ_reg_3(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1689 | return false; | ||
| 1690 | } | ||
| 1691 | virtual bool FRECPS_3(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1692 | return false; | ||
| 1693 | } | ||
| 1694 | virtual bool FRSQRTS_3(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1695 | return false; | ||
| 1696 | } | ||
| 1697 | virtual bool FCMGE_reg_3(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1698 | return false; | ||
| 1699 | } | ||
| 1700 | virtual bool FACGE_3(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1701 | return false; | ||
| 1702 | } | ||
| 1703 | virtual bool FABD_3(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1704 | return false; | ||
| 1705 | } | ||
| 1706 | virtual bool FCMGT_reg_3(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1707 | return false; | ||
| 1708 | } | ||
| 1709 | virtual bool FACGT_3(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1710 | return false; | ||
| 1711 | } | ||
| 1712 | virtual bool FMAXNM_1(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1713 | return false; | ||
| 1714 | } | ||
| 1715 | virtual bool FMLA_vec_1(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1716 | return false; | ||
| 1717 | } | ||
| 1718 | virtual bool FADD_1(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1719 | return false; | ||
| 1720 | } | ||
| 1721 | virtual bool FMAX_1(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1722 | return false; | ||
| 1723 | } | ||
| 1724 | virtual bool FMINNM_1(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1725 | return false; | ||
| 1726 | } | ||
| 1727 | virtual bool FMLS_vec_1(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1728 | return false; | ||
| 1729 | } | ||
| 1730 | virtual bool FSUB_1(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1731 | return false; | ||
| 1732 | } | ||
| 1733 | virtual bool FMIN_1(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1734 | return false; | ||
| 1735 | } | ||
| 1736 | virtual bool FMAXNMP_vec_1(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1737 | return false; | ||
| 1738 | } | ||
| 1739 | virtual bool FADDP_vec_1(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1740 | return false; | ||
| 1741 | } | ||
| 1742 | virtual bool FMUL_vec_1(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1743 | return false; | ||
| 1744 | } | ||
| 1745 | virtual bool FMAXP_vec_1(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1746 | return false; | ||
| 1747 | } | ||
| 1748 | virtual bool FDIV_1(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1749 | return false; | ||
| 1750 | } | ||
| 1751 | virtual bool FMINNMP_vec_1(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1752 | return false; | ||
| 1753 | } | ||
| 1754 | virtual bool FMINP_vec_1(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1755 | return false; | ||
| 1756 | } | ||
| 1757 | |||
| 1758 | // Data Processing - FP and SIMD - SIMD Three same extra | ||
| 1759 | virtual bool SDOT_vec(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1760 | return false; | ||
| 1761 | } | ||
| 1762 | virtual bool UDOT_vec(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1763 | return false; | ||
| 1764 | } | ||
| 1765 | virtual bool FCMLA_vec(bool Q, Imm<2> size, Vec Vm, Imm<2> rot, Vec Vn, Vec Vd) { | ||
| 1766 | return false; | ||
| 1767 | } | ||
| 1768 | virtual bool FCADD_vec(bool Q, Imm<2> size, Vec Vm, Imm<1> rot, Vec Vn, Vec Vd) { | ||
| 1769 | return false; | ||
| 1770 | } | ||
| 1771 | |||
| 1772 | // Data Processing - FP and SIMD - SIMD Two register misc | ||
| 1773 | virtual bool REV64_asimd(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1774 | return false; | ||
| 1775 | } | ||
| 1776 | virtual bool REV16_asimd(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1777 | return false; | ||
| 1778 | } | ||
| 1779 | virtual bool SADDLP(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1780 | return false; | ||
| 1781 | } | ||
| 1782 | virtual bool CLS_asimd(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1783 | return false; | ||
| 1784 | } | ||
| 1785 | virtual bool CNT(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1786 | return false; | ||
| 1787 | } | ||
| 1788 | virtual bool SADALP(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1789 | return false; | ||
| 1790 | } | ||
| 1791 | virtual bool XTN(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1792 | return false; | ||
| 1793 | } | ||
| 1794 | virtual bool FCVTN(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1795 | return false; | ||
| 1796 | } | ||
| 1797 | virtual bool FCVTL(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1798 | return false; | ||
| 1799 | } | ||
| 1800 | virtual bool URECPE(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1801 | return false; | ||
| 1802 | } | ||
| 1803 | virtual bool REV32_asimd(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1804 | return false; | ||
| 1805 | } | ||
| 1806 | virtual bool UADDLP(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1807 | return false; | ||
| 1808 | } | ||
| 1809 | virtual bool CLZ_asimd(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1810 | return false; | ||
| 1811 | } | ||
| 1812 | virtual bool UADALP(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1813 | return false; | ||
| 1814 | } | ||
| 1815 | virtual bool SHLL(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1816 | return false; | ||
| 1817 | } | ||
| 1818 | virtual bool NOT(bool Q, Vec Vn, Vec Vd) { | ||
| 1819 | return false; | ||
| 1820 | } | ||
| 1821 | virtual bool RBIT_asimd(bool Q, Vec Vn, Vec Vd) { | ||
| 1822 | return false; | ||
| 1823 | } | ||
| 1824 | virtual bool URSQRTE(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1825 | return false; | ||
| 1826 | } | ||
| 1827 | virtual bool SUQADD_2(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1828 | return false; | ||
| 1829 | } | ||
| 1830 | virtual bool SQABS_2(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1831 | return false; | ||
| 1832 | } | ||
| 1833 | virtual bool CMGT_zero_2(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1834 | return false; | ||
| 1835 | } | ||
| 1836 | virtual bool CMEQ_zero_2(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1837 | return false; | ||
| 1838 | } | ||
| 1839 | virtual bool CMLT_2(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1840 | return false; | ||
| 1841 | } | ||
| 1842 | virtual bool ABS_2(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1843 | return false; | ||
| 1844 | } | ||
| 1845 | virtual bool SQXTN_2(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1846 | return false; | ||
| 1847 | } | ||
| 1848 | virtual bool USQADD_2(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1849 | return false; | ||
| 1850 | } | ||
| 1851 | virtual bool SQNEG_2(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1852 | return false; | ||
| 1853 | } | ||
| 1854 | virtual bool CMGE_zero_2(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1855 | return false; | ||
| 1856 | } | ||
| 1857 | virtual bool CMLE_2(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1858 | return false; | ||
| 1859 | } | ||
| 1860 | virtual bool NEG_2(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1861 | return false; | ||
| 1862 | } | ||
| 1863 | virtual bool SQXTUN_2(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1864 | return false; | ||
| 1865 | } | ||
| 1866 | virtual bool UQXTN_2(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1867 | return false; | ||
| 1868 | } | ||
| 1869 | virtual bool FCVTXN_2(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1870 | return false; | ||
| 1871 | } | ||
| 1872 | virtual bool FRINTN_1(bool Q, Vec Vn, Vec Vd) { | ||
| 1873 | return false; | ||
| 1874 | } | ||
| 1875 | virtual bool FRINTN_2(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1876 | return false; | ||
| 1877 | } | ||
| 1878 | virtual bool FRINTM_1(bool Q, Vec Vn, Vec Vd) { | ||
| 1879 | return false; | ||
| 1880 | } | ||
| 1881 | virtual bool FRINTM_2(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1882 | return false; | ||
| 1883 | } | ||
| 1884 | virtual bool FABS_1(bool Q, Vec Vn, Vec Vd) { | ||
| 1885 | return false; | ||
| 1886 | } | ||
| 1887 | virtual bool FABS_2(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1888 | return false; | ||
| 1889 | } | ||
| 1890 | virtual bool FRINTP_1(bool Q, Vec Vn, Vec Vd) { | ||
| 1891 | return false; | ||
| 1892 | } | ||
| 1893 | virtual bool FRINTP_2(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1894 | return false; | ||
| 1895 | } | ||
| 1896 | virtual bool FRINTZ_1(bool Q, Vec Vn, Vec Vd) { | ||
| 1897 | return false; | ||
| 1898 | } | ||
| 1899 | virtual bool FRINTZ_2(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1900 | return false; | ||
| 1901 | } | ||
| 1902 | virtual bool FRINTA_1(bool Q, Vec Vn, Vec Vd) { | ||
| 1903 | return false; | ||
| 1904 | } | ||
| 1905 | virtual bool FRINTA_2(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1906 | return false; | ||
| 1907 | } | ||
| 1908 | virtual bool FRINTX_1(bool Q, Vec Vn, Vec Vd) { | ||
| 1909 | return false; | ||
| 1910 | } | ||
| 1911 | virtual bool FRINTX_2(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1912 | return false; | ||
| 1913 | } | ||
| 1914 | virtual bool FNEG_1(bool Q, Vec Vn, Vec Vd) { | ||
| 1915 | return false; | ||
| 1916 | } | ||
| 1917 | virtual bool FNEG_2(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1918 | return false; | ||
| 1919 | } | ||
| 1920 | virtual bool FRINTI_1(bool Q, Vec Vn, Vec Vd) { | ||
| 1921 | return false; | ||
| 1922 | } | ||
| 1923 | virtual bool FRINTI_2(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1924 | return false; | ||
| 1925 | } | ||
| 1926 | virtual bool FSQRT_1(bool Q, Vec Vn, Vec Vd) { | ||
| 1927 | return false; | ||
| 1928 | } | ||
| 1929 | virtual bool FSQRT_2(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1930 | return false; | ||
| 1931 | } | ||
| 1932 | virtual bool FRINT32X_1(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1933 | return false; | ||
| 1934 | } | ||
| 1935 | virtual bool FRINT64X_1(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1936 | return false; | ||
| 1937 | } | ||
| 1938 | virtual bool FRINT32Z_1(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1939 | return false; | ||
| 1940 | } | ||
| 1941 | virtual bool FRINT64Z_1(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1942 | return false; | ||
| 1943 | } | ||
| 1944 | |||
| 1945 | // Data Processing - FP and SIMD - SIMD across lanes | ||
| 1946 | virtual bool SADDLV(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1947 | return false; | ||
| 1948 | } | ||
| 1949 | virtual bool SMAXV(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1950 | return false; | ||
| 1951 | } | ||
| 1952 | virtual bool SMINV(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1953 | return false; | ||
| 1954 | } | ||
| 1955 | virtual bool ADDV(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1956 | return false; | ||
| 1957 | } | ||
| 1958 | virtual bool FMAXNMV_1(bool Q, Vec Vn, Vec Vd) { | ||
| 1959 | return false; | ||
| 1960 | } | ||
| 1961 | virtual bool FMAXNMV_2(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1962 | return false; | ||
| 1963 | } | ||
| 1964 | virtual bool FMAXV_1(bool Q, Vec Vn, Vec Vd) { | ||
| 1965 | return false; | ||
| 1966 | } | ||
| 1967 | virtual bool FMAXV_2(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1968 | return false; | ||
| 1969 | } | ||
| 1970 | virtual bool FMINNMV_1(bool Q, Vec Vn, Vec Vd) { | ||
| 1971 | return false; | ||
| 1972 | } | ||
| 1973 | virtual bool FMINNMV_2(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1974 | return false; | ||
| 1975 | } | ||
| 1976 | virtual bool FMINV_1(bool Q, Vec Vn, Vec Vd) { | ||
| 1977 | return false; | ||
| 1978 | } | ||
| 1979 | virtual bool FMINV_2(bool Q, bool sz, Vec Vn, Vec Vd) { | ||
| 1980 | return false; | ||
| 1981 | } | ||
| 1982 | virtual bool UADDLV(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1983 | return false; | ||
| 1984 | } | ||
| 1985 | virtual bool UMAXV(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1986 | return false; | ||
| 1987 | } | ||
| 1988 | virtual bool UMINV(bool Q, Imm<2> size, Vec Vn, Vec Vd) { | ||
| 1989 | return false; | ||
| 1990 | } | ||
| 1991 | |||
| 1992 | // Data Processing - FP and SIMD - SIMD three different | ||
| 1993 | virtual bool SADDL(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1994 | return false; | ||
| 1995 | } | ||
| 1996 | virtual bool SADDW(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 1997 | return false; | ||
| 1998 | } | ||
| 1999 | virtual bool SSUBL(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2000 | return false; | ||
| 2001 | } | ||
| 2002 | virtual bool SSUBW(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2003 | return false; | ||
| 2004 | } | ||
| 2005 | virtual bool ADDHN(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2006 | return false; | ||
| 2007 | } | ||
| 2008 | virtual bool SABAL(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2009 | return false; | ||
| 2010 | } | ||
| 2011 | virtual bool SUBHN(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2012 | return false; | ||
| 2013 | } | ||
| 2014 | virtual bool SABDL(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2015 | return false; | ||
| 2016 | } | ||
| 2017 | virtual bool SMLAL_vec(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2018 | return false; | ||
| 2019 | } | ||
| 2020 | virtual bool SMLSL_vec(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2021 | return false; | ||
| 2022 | } | ||
| 2023 | virtual bool SMULL_vec(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2024 | return false; | ||
| 2025 | } | ||
| 2026 | virtual bool PMULL(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2027 | return false; | ||
| 2028 | } | ||
| 2029 | virtual bool UADDL(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2030 | return false; | ||
| 2031 | } | ||
| 2032 | virtual bool UADDW(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2033 | return false; | ||
| 2034 | } | ||
| 2035 | virtual bool USUBL(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2036 | return false; | ||
| 2037 | } | ||
| 2038 | virtual bool USUBW(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2039 | return false; | ||
| 2040 | } | ||
| 2041 | virtual bool RADDHN(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2042 | return false; | ||
| 2043 | } | ||
| 2044 | virtual bool UABAL(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2045 | return false; | ||
| 2046 | } | ||
| 2047 | virtual bool RSUBHN(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2048 | return false; | ||
| 2049 | } | ||
| 2050 | virtual bool UABDL(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2051 | return false; | ||
| 2052 | } | ||
| 2053 | virtual bool UMLAL_vec(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2054 | return false; | ||
| 2055 | } | ||
| 2056 | virtual bool UMLSL_vec(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2057 | return false; | ||
| 2058 | } | ||
| 2059 | virtual bool UMULL_vec(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2060 | return false; | ||
| 2061 | } | ||
| 2062 | virtual bool SQDMLAL_vec_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2063 | return false; | ||
| 2064 | } | ||
| 2065 | virtual bool SQDMLSL_vec_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2066 | return false; | ||
| 2067 | } | ||
| 2068 | virtual bool SQDMULL_vec_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2069 | return false; | ||
| 2070 | } | ||
| 2071 | |||
| 2072 | // Data Processing - FP and SIMD - SIMD three same | ||
| 2073 | virtual bool SHADD(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2074 | return false; | ||
| 2075 | } | ||
| 2076 | virtual bool SRHADD(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2077 | return false; | ||
| 2078 | } | ||
| 2079 | virtual bool SHSUB(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2080 | return false; | ||
| 2081 | } | ||
| 2082 | virtual bool SMAX(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2083 | return false; | ||
| 2084 | } | ||
| 2085 | virtual bool SMIN(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2086 | return false; | ||
| 2087 | } | ||
| 2088 | virtual bool SABD(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2089 | return false; | ||
| 2090 | } | ||
| 2091 | virtual bool SABA(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2092 | return false; | ||
| 2093 | } | ||
| 2094 | virtual bool MLA_vec(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2095 | return false; | ||
| 2096 | } | ||
| 2097 | virtual bool MUL_vec(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2098 | return false; | ||
| 2099 | } | ||
| 2100 | virtual bool SMAXP(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2101 | return false; | ||
| 2102 | } | ||
| 2103 | virtual bool SMINP(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2104 | return false; | ||
| 2105 | } | ||
| 2106 | virtual bool ADDP_vec(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2107 | return false; | ||
| 2108 | } | ||
| 2109 | virtual bool FMLAL_vec_1(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2110 | return false; | ||
| 2111 | } | ||
| 2112 | virtual bool FMLAL_vec_2(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2113 | return false; | ||
| 2114 | } | ||
| 2115 | virtual bool AND_asimd(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2116 | return false; | ||
| 2117 | } | ||
| 2118 | virtual bool BIC_asimd_reg(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2119 | return false; | ||
| 2120 | } | ||
| 2121 | virtual bool FMLSL_vec_1(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2122 | return false; | ||
| 2123 | } | ||
| 2124 | virtual bool FMLSL_vec_2(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2125 | return false; | ||
| 2126 | } | ||
| 2127 | virtual bool ORR_asimd_reg(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2128 | return false; | ||
| 2129 | } | ||
| 2130 | virtual bool ORN_asimd(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2131 | return false; | ||
| 2132 | } | ||
| 2133 | virtual bool UHADD(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2134 | return false; | ||
| 2135 | } | ||
| 2136 | virtual bool URHADD(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2137 | return false; | ||
| 2138 | } | ||
| 2139 | virtual bool UHSUB(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2140 | return false; | ||
| 2141 | } | ||
| 2142 | virtual bool UMAX(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2143 | return false; | ||
| 2144 | } | ||
| 2145 | virtual bool UMIN(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2146 | return false; | ||
| 2147 | } | ||
| 2148 | virtual bool UABD(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2149 | return false; | ||
| 2150 | } | ||
| 2151 | virtual bool UABA(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2152 | return false; | ||
| 2153 | } | ||
| 2154 | virtual bool MLS_vec(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2155 | return false; | ||
| 2156 | } | ||
| 2157 | virtual bool PMUL(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2158 | return false; | ||
| 2159 | } | ||
| 2160 | virtual bool UMAXP(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2161 | return false; | ||
| 2162 | } | ||
| 2163 | virtual bool UMINP(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2164 | return false; | ||
| 2165 | } | ||
| 2166 | virtual bool EOR_asimd(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2167 | return false; | ||
| 2168 | } | ||
| 2169 | virtual bool BSL(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2170 | return false; | ||
| 2171 | } | ||
| 2172 | virtual bool BIT(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2173 | return false; | ||
| 2174 | } | ||
| 2175 | virtual bool BIF(bool Q, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2176 | return false; | ||
| 2177 | } | ||
| 2178 | virtual bool FMAXNM_2(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2179 | return false; | ||
| 2180 | } | ||
| 2181 | virtual bool FMLA_vec_2(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2182 | return false; | ||
| 2183 | } | ||
| 2184 | virtual bool FADD_2(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2185 | return false; | ||
| 2186 | } | ||
| 2187 | virtual bool FMAX_2(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2188 | return false; | ||
| 2189 | } | ||
| 2190 | virtual bool FMINNM_2(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2191 | return false; | ||
| 2192 | } | ||
| 2193 | virtual bool FMLS_vec_2(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2194 | return false; | ||
| 2195 | } | ||
| 2196 | virtual bool FSUB_2(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2197 | return false; | ||
| 2198 | } | ||
| 2199 | virtual bool FMIN_2(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2200 | return false; | ||
| 2201 | } | ||
| 2202 | virtual bool FMAXNMP_vec_2(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2203 | return false; | ||
| 2204 | } | ||
| 2205 | virtual bool FADDP_vec_2(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2206 | return false; | ||
| 2207 | } | ||
| 2208 | virtual bool FMUL_vec_2(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2209 | return false; | ||
| 2210 | } | ||
| 2211 | virtual bool FMAXP_vec_2(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2212 | return false; | ||
| 2213 | } | ||
| 2214 | virtual bool FDIV_2(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2215 | return false; | ||
| 2216 | } | ||
| 2217 | virtual bool FMINNMP_vec_2(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2218 | return false; | ||
| 2219 | } | ||
| 2220 | virtual bool FMINP_vec_2(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2221 | return false; | ||
| 2222 | } | ||
| 2223 | virtual bool FMULX_vec_4(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2224 | return false; | ||
| 2225 | } | ||
| 2226 | virtual bool FCMEQ_reg_4(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2227 | return false; | ||
| 2228 | } | ||
| 2229 | virtual bool FRECPS_4(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2230 | return false; | ||
| 2231 | } | ||
| 2232 | virtual bool FRSQRTS_4(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2233 | return false; | ||
| 2234 | } | ||
| 2235 | virtual bool FCMGE_reg_4(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2236 | return false; | ||
| 2237 | } | ||
| 2238 | virtual bool FACGE_4(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2239 | return false; | ||
| 2240 | } | ||
| 2241 | virtual bool FABD_4(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2242 | return false; | ||
| 2243 | } | ||
| 2244 | virtual bool FCMGT_reg_4(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2245 | return false; | ||
| 2246 | } | ||
| 2247 | virtual bool FACGT_4(bool Q, bool sz, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2248 | return false; | ||
| 2249 | } | ||
| 2250 | virtual bool SQADD_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2251 | return false; | ||
| 2252 | } | ||
| 2253 | virtual bool SQSUB_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2254 | return false; | ||
| 2255 | } | ||
| 2256 | virtual bool CMGT_reg_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2257 | return false; | ||
| 2258 | } | ||
| 2259 | virtual bool CMGE_reg_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2260 | return false; | ||
| 2261 | } | ||
| 2262 | virtual bool SSHL_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2263 | return false; | ||
| 2264 | } | ||
| 2265 | virtual bool SQSHL_reg_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2266 | return false; | ||
| 2267 | } | ||
| 2268 | virtual bool SRSHL_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2269 | return false; | ||
| 2270 | } | ||
| 2271 | virtual bool SQRSHL_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2272 | return false; | ||
| 2273 | } | ||
| 2274 | virtual bool ADD_vector(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2275 | return false; | ||
| 2276 | } | ||
| 2277 | virtual bool CMTST_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2278 | return false; | ||
| 2279 | } | ||
| 2280 | virtual bool SQDMULH_vec_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2281 | return false; | ||
| 2282 | } | ||
| 2283 | virtual bool UQADD_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2284 | return false; | ||
| 2285 | } | ||
| 2286 | virtual bool UQSUB_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2287 | return false; | ||
| 2288 | } | ||
| 2289 | virtual bool CMHI_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2290 | return false; | ||
| 2291 | } | ||
| 2292 | virtual bool CMHS_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2293 | return false; | ||
| 2294 | } | ||
| 2295 | virtual bool USHL_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2296 | return false; | ||
| 2297 | } | ||
| 2298 | virtual bool UQSHL_reg_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2299 | return false; | ||
| 2300 | } | ||
| 2301 | virtual bool URSHL_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2302 | return false; | ||
| 2303 | } | ||
| 2304 | virtual bool UQRSHL_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2305 | return false; | ||
| 2306 | } | ||
| 2307 | virtual bool SUB_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2308 | return false; | ||
| 2309 | } | ||
| 2310 | virtual bool CMEQ_reg_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2311 | return false; | ||
| 2312 | } | ||
| 2313 | virtual bool SQRDMULH_vec_2(bool Q, Imm<2> size, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2314 | return false; | ||
| 2315 | } | ||
| 2316 | |||
| 2317 | // Data Processing - FP and SIMD - SIMD modified immediate | ||
| 2318 | virtual bool MOVI(bool Q, bool op, Imm<1> a, Imm<1> b, Imm<1> c, Imm<4> cmode, Imm<1> d, | ||
| 2319 | Imm<1> e, Imm<1> f, Imm<1> g, Imm<1> h, Vec Vd) { | ||
| 2320 | return false; | ||
| 2321 | } | ||
| 2322 | virtual bool FMOV_2(bool Q, bool op, Imm<1> a, Imm<1> b, Imm<1> c, Imm<1> d, Imm<1> e, Imm<1> f, | ||
| 2323 | Imm<1> g, Imm<1> h, Vec Vd) { | ||
| 2324 | return false; | ||
| 2325 | } | ||
| 2326 | virtual bool FMOV_3(bool Q, Imm<1> a, Imm<1> b, Imm<1> c, Imm<1> d, Imm<1> e, Imm<1> f, | ||
| 2327 | Imm<1> g, Imm<1> h, Vec Vd) { | ||
| 2328 | return false; | ||
| 2329 | } | ||
| 2330 | |||
| 2331 | // Data Processing - FP and SIMD - SIMD Shift by immediate | ||
| 2332 | virtual bool SSHR_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2333 | return false; | ||
| 2334 | } | ||
| 2335 | virtual bool SSRA_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2336 | return false; | ||
| 2337 | } | ||
| 2338 | virtual bool SRSHR_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2339 | return false; | ||
| 2340 | } | ||
| 2341 | virtual bool SRSRA_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2342 | return false; | ||
| 2343 | } | ||
| 2344 | virtual bool SHL_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2345 | return false; | ||
| 2346 | } | ||
| 2347 | virtual bool SQSHL_imm_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2348 | return false; | ||
| 2349 | } | ||
| 2350 | virtual bool SHRN(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2351 | return false; | ||
| 2352 | } | ||
| 2353 | virtual bool RSHRN(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2354 | return false; | ||
| 2355 | } | ||
| 2356 | virtual bool SQSHRN_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2357 | return false; | ||
| 2358 | } | ||
| 2359 | virtual bool SQRSHRN_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2360 | return false; | ||
| 2361 | } | ||
| 2362 | virtual bool SSHLL(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2363 | return false; | ||
| 2364 | } | ||
| 2365 | virtual bool SCVTF_fix_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2366 | return false; | ||
| 2367 | } | ||
| 2368 | virtual bool FCVTZS_fix_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2369 | return false; | ||
| 2370 | } | ||
| 2371 | virtual bool USHR_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2372 | return false; | ||
| 2373 | } | ||
| 2374 | virtual bool USRA_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2375 | return false; | ||
| 2376 | } | ||
| 2377 | virtual bool URSHR_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2378 | return false; | ||
| 2379 | } | ||
| 2380 | virtual bool URSRA_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2381 | return false; | ||
| 2382 | } | ||
| 2383 | virtual bool SRI_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2384 | return false; | ||
| 2385 | } | ||
| 2386 | virtual bool SLI_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2387 | return false; | ||
| 2388 | } | ||
| 2389 | virtual bool SQSHLU_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2390 | return false; | ||
| 2391 | } | ||
| 2392 | virtual bool UQSHL_imm_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2393 | return false; | ||
| 2394 | } | ||
| 2395 | virtual bool SQSHRUN_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2396 | return false; | ||
| 2397 | } | ||
| 2398 | virtual bool SQRSHRUN_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2399 | return false; | ||
| 2400 | } | ||
| 2401 | virtual bool UQSHRN_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2402 | return false; | ||
| 2403 | } | ||
| 2404 | virtual bool UQRSHRN_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2405 | return false; | ||
| 2406 | } | ||
| 2407 | virtual bool USHLL(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2408 | return false; | ||
| 2409 | } | ||
| 2410 | virtual bool UCVTF_fix_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2411 | return false; | ||
| 2412 | } | ||
| 2413 | virtual bool FCVTZU_fix_2(bool Q, Imm<4> immh, Imm<3> immb, Vec Vn, Vec Vd) { | ||
| 2414 | return false; | ||
| 2415 | } | ||
| 2416 | |||
| 2417 | // Data Processing - FP and SIMD - SIMD vector x indexed element | ||
| 2418 | virtual bool SMLAL_elt(bool Q, Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 2419 | Vec Vd) { | ||
| 2420 | return false; | ||
| 2421 | } | ||
| 2422 | virtual bool SQDMLAL_elt_2(bool Q, Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, | ||
| 2423 | Vec Vn, Vec Vd) { | ||
| 2424 | return false; | ||
| 2425 | } | ||
| 2426 | virtual bool SMLSL_elt(bool Q, Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 2427 | Vec Vd) { | ||
| 2428 | return false; | ||
| 2429 | } | ||
| 2430 | virtual bool SQDMLSL_elt_2(bool Q, Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, | ||
| 2431 | Vec Vn, Vec Vd) { | ||
| 2432 | return false; | ||
| 2433 | } | ||
| 2434 | virtual bool MUL_elt(bool Q, Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 2435 | Vec Vd) { | ||
| 2436 | return false; | ||
| 2437 | } | ||
| 2438 | virtual bool SMULL_elt(bool Q, Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vm, Imm<1> H, Vec Vn, | ||
| 2439 | Vec Vd) { | ||
| 2440 | return false; | ||
| 2441 | } | ||
| 2442 | virtual bool SQDMULL_elt_2(bool Q, Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, | ||
| 2443 | Vec Vn, Vec Vd) { | ||
| 2444 | return false; | ||
| 2445 | } | ||
| 2446 | virtual bool SQDMULH_elt_2(bool Q, Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, | ||
| 2447 | Vec Vn, Vec Vd) { | ||
| 2448 | return false; | ||
| 2449 | } | ||
| 2450 | virtual bool SQRDMULH_elt_2(bool Q, Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, | ||
| 2451 | Vec Vn, Vec Vd) { | ||
| 2452 | return false; | ||
| 2453 | } | ||
| 2454 | virtual bool SDOT_elt(bool Q, Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 2455 | Vec Vd) { | ||
| 2456 | return false; | ||
| 2457 | } | ||
| 2458 | virtual bool FMLA_elt_3(bool Q, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, Vec Vd) { | ||
| 2459 | return false; | ||
| 2460 | } | ||
| 2461 | virtual bool FMLA_elt_4(bool Q, bool sz, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 2462 | Vec Vd) { | ||
| 2463 | return false; | ||
| 2464 | } | ||
| 2465 | virtual bool FMLS_elt_3(bool Q, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, Vec Vd) { | ||
| 2466 | return false; | ||
| 2467 | } | ||
| 2468 | virtual bool FMLS_elt_4(bool Q, bool sz, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 2469 | Vec Vd) { | ||
| 2470 | return false; | ||
| 2471 | } | ||
| 2472 | virtual bool FMUL_elt_3(bool Q, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, Vec Vd) { | ||
| 2473 | return false; | ||
| 2474 | } | ||
| 2475 | virtual bool FMUL_elt_4(bool Q, bool sz, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 2476 | Vec Vd) { | ||
| 2477 | return false; | ||
| 2478 | } | ||
| 2479 | virtual bool FMLAL_elt_1(bool Q, bool sz, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 2480 | Vec Vd) { | ||
| 2481 | return false; | ||
| 2482 | } | ||
| 2483 | virtual bool FMLAL_elt_2(bool Q, bool sz, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 2484 | Vec Vd) { | ||
| 2485 | return false; | ||
| 2486 | } | ||
| 2487 | virtual bool FMLSL_elt_1(bool Q, bool sz, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 2488 | Vec Vd) { | ||
| 2489 | return false; | ||
| 2490 | } | ||
| 2491 | virtual bool FMLSL_elt_2(bool Q, bool sz, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 2492 | Vec Vd) { | ||
| 2493 | return false; | ||
| 2494 | } | ||
| 2495 | virtual bool MLA_elt(bool Q, Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 2496 | Vec Vd) { | ||
| 2497 | return false; | ||
| 2498 | } | ||
| 2499 | virtual bool UMLAL_elt(bool Q, Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 2500 | Vec Vd) { | ||
| 2501 | return false; | ||
| 2502 | } | ||
| 2503 | virtual bool MLS_elt(bool Q, Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 2504 | Vec Vd) { | ||
| 2505 | return false; | ||
| 2506 | } | ||
| 2507 | virtual bool UMLSL_elt(bool Q, Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 2508 | Vec Vd) { | ||
| 2509 | return false; | ||
| 2510 | } | ||
| 2511 | virtual bool UMULL_elt(bool Q, Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 2512 | Vec Vd) { | ||
| 2513 | return false; | ||
| 2514 | } | ||
| 2515 | virtual bool SQRDMLAH_elt_2(bool Q, Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, | ||
| 2516 | Vec Vn, Vec Vd) { | ||
| 2517 | return false; | ||
| 2518 | } | ||
| 2519 | virtual bool UDOT_elt(bool Q, Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 2520 | Vec Vd) { | ||
| 2521 | return false; | ||
| 2522 | } | ||
| 2523 | virtual bool SQRDMLSH_elt_2(bool Q, Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, | ||
| 2524 | Vec Vn, Vec Vd) { | ||
| 2525 | return false; | ||
| 2526 | } | ||
| 2527 | virtual bool FMULX_elt_3(bool Q, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, Vec Vd) { | ||
| 2528 | return false; | ||
| 2529 | } | ||
| 2530 | virtual bool FMULX_elt_4(bool Q, bool sz, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<1> H, Vec Vn, | ||
| 2531 | Vec Vd) { | ||
| 2532 | return false; | ||
| 2533 | } | ||
| 2534 | virtual bool FCMLA_elt(bool Q, Imm<2> size, Imm<1> L, Imm<1> M, Imm<4> Vmlo, Imm<2> rot, | ||
| 2535 | Imm<1> H, Vec Vn, Vec Vd) { | ||
| 2536 | return false; | ||
| 2537 | } | ||
| 2538 | |||
| 2539 | // Data Processing - FP and SIMD - Cryptographic three register | ||
| 2540 | virtual bool SM3TT1A(Vec Vm, Imm<2> imm2, Vec Vn, Vec Vd) { | ||
| 2541 | return false; | ||
| 2542 | } | ||
| 2543 | virtual bool SM3TT1B(Vec Vm, Imm<2> imm2, Vec Vn, Vec Vd) { | ||
| 2544 | return false; | ||
| 2545 | } | ||
| 2546 | virtual bool SM3TT2A(Vec Vm, Imm<2> imm2, Vec Vn, Vec Vd) { | ||
| 2547 | return false; | ||
| 2548 | } | ||
| 2549 | virtual bool SM3TT2B(Vec Vm, Imm<2> imm2, Vec Vn, Vec Vd) { | ||
| 2550 | return false; | ||
| 2551 | } | ||
| 2552 | |||
| 2553 | // Data Processing - FP and SIMD - SHA512 three register | ||
| 2554 | virtual bool SHA512H(Vec Vm, Vec Vn, Vec Vd) { | ||
| 2555 | return false; | ||
| 2556 | } | ||
| 2557 | virtual bool SHA512H2(Vec Vm, Vec Vn, Vec Vd) { | ||
| 2558 | return false; | ||
| 2559 | } | ||
| 2560 | virtual bool SHA512SU1(Vec Vm, Vec Vn, Vec Vd) { | ||
| 2561 | return false; | ||
| 2562 | } | ||
| 2563 | virtual bool RAX1(Vec Vm, Vec Vn, Vec Vd) { | ||
| 2564 | return false; | ||
| 2565 | } | ||
| 2566 | virtual bool XAR(Vec Vm, Imm<6> imm6, Vec Vn, Vec Vd) { | ||
| 2567 | return false; | ||
| 2568 | } | ||
| 2569 | virtual bool SM3PARTW1(Vec Vm, Vec Vn, Vec Vd) { | ||
| 2570 | return false; | ||
| 2571 | } | ||
| 2572 | virtual bool SM3PARTW2(Vec Vm, Vec Vn, Vec Vd) { | ||
| 2573 | return false; | ||
| 2574 | } | ||
| 2575 | virtual bool SM4EKEY(Vec Vm, Vec Vn, Vec Vd) { | ||
| 2576 | return false; | ||
| 2577 | } | ||
| 2578 | |||
| 2579 | // Data Processing - FP and SIMD - Cryptographic four register | ||
| 2580 | virtual bool EOR3(Vec Vm, Vec Va, Vec Vn, Vec Vd) { | ||
| 2581 | return false; | ||
| 2582 | } | ||
| 2583 | virtual bool BCAX(Vec Vm, Vec Va, Vec Vn, Vec Vd) { | ||
| 2584 | return false; | ||
| 2585 | } | ||
| 2586 | virtual bool SM3SS1(Vec Vm, Vec Va, Vec Vn, Vec Vd) { | ||
| 2587 | return false; | ||
| 2588 | } | ||
| 2589 | |||
| 2590 | // Data Processing - FP and SIMD - SHA512 two register | ||
| 2591 | virtual bool SHA512SU0(Vec Vn, Vec Vd) { | ||
| 2592 | return false; | ||
| 2593 | } | ||
| 2594 | virtual bool SM4E(Vec Vn, Vec Vd) { | ||
| 2595 | return false; | ||
| 2596 | } | ||
| 2597 | |||
| 2598 | // Data Processing - FP and SIMD - Conversion between floating point and fixed point | ||
| 2599 | virtual bool SCVTF_float_fix(bool sf, Imm<2> type, Imm<6> scale, Reg Rn, Vec Vd) { | ||
| 2600 | return false; | ||
| 2601 | } | ||
| 2602 | virtual bool UCVTF_float_fix(bool sf, Imm<2> type, Imm<6> scale, Reg Rn, Vec Vd) { | ||
| 2603 | return false; | ||
| 2604 | } | ||
| 2605 | virtual bool FCVTZS_float_fix(bool sf, Imm<2> type, Imm<6> scale, Vec Vn, Reg Rd) { | ||
| 2606 | return false; | ||
| 2607 | } | ||
| 2608 | virtual bool FCVTZU_float_fix(bool sf, Imm<2> type, Imm<6> scale, Vec Vn, Reg Rd) { | ||
| 2609 | return false; | ||
| 2610 | } | ||
| 2611 | |||
| 2612 | // Data Processing - FP and SIMD - Conversion between floating point and integer | ||
| 2613 | virtual bool FCVTNS_float(bool sf, Imm<2> type, Vec Vn, Reg Rd) { | ||
| 2614 | return false; | ||
| 2615 | } | ||
| 2616 | virtual bool FCVTNU_float(bool sf, Imm<2> type, Vec Vn, Reg Rd) { | ||
| 2617 | return false; | ||
| 2618 | } | ||
| 2619 | virtual bool SCVTF_float_int(bool sf, Imm<2> type, Reg Rn, Vec Vd) { | ||
| 2620 | return false; | ||
| 2621 | } | ||
| 2622 | virtual bool UCVTF_float_int(bool sf, Imm<2> type, Reg Rn, Vec Vd) { | ||
| 2623 | return false; | ||
| 2624 | } | ||
| 2625 | virtual bool FCVTAS_float(bool sf, Imm<2> type, Vec Vn, Reg Rd) { | ||
| 2626 | return false; | ||
| 2627 | } | ||
| 2628 | virtual bool FCVTAU_float(bool sf, Imm<2> type, Vec Vn, Reg Rd) { | ||
| 2629 | return false; | ||
| 2630 | } | ||
| 2631 | virtual bool FMOV_float_gen(bool sf, Imm<2> type, Imm<1> rmode_0, Imm<1> opc_0, size_t n, | ||
| 2632 | size_t d) { | ||
| 2633 | return false; | ||
| 2634 | } | ||
| 2635 | virtual bool FCVTPS_float(bool sf, Imm<2> type, Vec Vn, Reg Rd) { | ||
| 2636 | return false; | ||
| 2637 | } | ||
| 2638 | virtual bool FCVTPU_float(bool sf, Imm<2> type, Vec Vn, Reg Rd) { | ||
| 2639 | return false; | ||
| 2640 | } | ||
| 2641 | virtual bool FCVTMS_float(bool sf, Imm<2> type, Vec Vn, Reg Rd) { | ||
| 2642 | return false; | ||
| 2643 | } | ||
| 2644 | virtual bool FCVTMU_float(bool sf, Imm<2> type, Vec Vn, Reg Rd) { | ||
| 2645 | return false; | ||
| 2646 | } | ||
| 2647 | virtual bool FCVTZS_float_int(bool sf, Imm<2> type, Vec Vn, Reg Rd) { | ||
| 2648 | return false; | ||
| 2649 | } | ||
| 2650 | virtual bool FCVTZU_float_int(bool sf, Imm<2> type, Vec Vn, Reg Rd) { | ||
| 2651 | return false; | ||
| 2652 | } | ||
| 2653 | virtual bool FJCVTZS(Vec Vn, Reg Rd) { | ||
| 2654 | return false; | ||
| 2655 | } | ||
| 2656 | |||
| 2657 | // Data Processing - FP and SIMD - Floating point data processing | ||
| 2658 | virtual bool FMOV_float(Imm<2> type, Vec Vn, Vec Vd) { | ||
| 2659 | return false; | ||
| 2660 | } | ||
| 2661 | virtual bool FABS_float(Imm<2> type, Vec Vn, Vec Vd) { | ||
| 2662 | return false; | ||
| 2663 | } | ||
| 2664 | virtual bool FNEG_float(Imm<2> type, Vec Vn, Vec Vd) { | ||
| 2665 | return false; | ||
| 2666 | } | ||
| 2667 | virtual bool FSQRT_float(Imm<2> type, Vec Vn, Vec Vd) { | ||
| 2668 | return false; | ||
| 2669 | } | ||
| 2670 | virtual bool FCVT_float(Imm<2> type, Imm<2> opc, Vec Vn, Vec Vd) { | ||
| 2671 | return false; | ||
| 2672 | } | ||
| 2673 | virtual bool FRINTN_float(Imm<2> type, Vec Vn, Vec Vd) { | ||
| 2674 | return false; | ||
| 2675 | } | ||
| 2676 | virtual bool FRINTP_float(Imm<2> type, Vec Vn, Vec Vd) { | ||
| 2677 | return false; | ||
| 2678 | } | ||
| 2679 | virtual bool FRINTM_float(Imm<2> type, Vec Vn, Vec Vd) { | ||
| 2680 | return false; | ||
| 2681 | } | ||
| 2682 | virtual bool FRINTZ_float(Imm<2> type, Vec Vn, Vec Vd) { | ||
| 2683 | return false; | ||
| 2684 | } | ||
| 2685 | virtual bool FRINTA_float(Imm<2> type, Vec Vn, Vec Vd) { | ||
| 2686 | return false; | ||
| 2687 | } | ||
| 2688 | virtual bool FRINTX_float(Imm<2> type, Vec Vn, Vec Vd) { | ||
| 2689 | return false; | ||
| 2690 | } | ||
| 2691 | virtual bool FRINTI_float(Imm<2> type, Vec Vn, Vec Vd) { | ||
| 2692 | return false; | ||
| 2693 | } | ||
| 2694 | virtual bool FRINT32X_float(Imm<2> type, Vec Vn, Vec Vd) { | ||
| 2695 | return false; | ||
| 2696 | } | ||
| 2697 | virtual bool FRINT64X_float(Imm<2> type, Vec Vn, Vec Vd) { | ||
| 2698 | return false; | ||
| 2699 | } | ||
| 2700 | virtual bool FRINT32Z_float(Imm<2> type, Vec Vn, Vec Vd) { | ||
| 2701 | return false; | ||
| 2702 | } | ||
| 2703 | virtual bool FRINT64Z_float(Imm<2> type, Vec Vn, Vec Vd) { | ||
| 2704 | return false; | ||
| 2705 | } | ||
| 2706 | |||
| 2707 | // Data Processing - FP and SIMD - Floating point compare | ||
| 2708 | virtual bool FCMP_float(Imm<2> type, Vec Vm, Vec Vn, bool cmp_with_zero) { | ||
| 2709 | return false; | ||
| 2710 | } | ||
| 2711 | virtual bool FCMPE_float(Imm<2> type, Vec Vm, Vec Vn, bool cmp_with_zero) { | ||
| 2712 | return false; | ||
| 2713 | } | ||
| 2714 | |||
| 2715 | // Data Processing - FP and SIMD - Floating point immediate | ||
| 2716 | virtual bool FMOV_float_imm(Imm<2> type, Imm<8> imm8, Vec Vd) { | ||
| 2717 | return false; | ||
| 2718 | } | ||
| 2719 | |||
| 2720 | // Data Processing - FP and SIMD - Floating point conditional compare | ||
| 2721 | virtual bool FCCMP_float(Imm<2> type, Vec Vm, Cond cond, Vec Vn, Imm<4> nzcv) { | ||
| 2722 | return false; | ||
| 2723 | } | ||
| 2724 | virtual bool FCCMPE_float(Imm<2> type, Vec Vm, Cond cond, Vec Vn, Imm<4> nzcv) { | ||
| 2725 | return false; | ||
| 2726 | } | ||
| 2727 | |||
| 2728 | // Data Processing - FP and SIMD - Floating point data processing two register | ||
| 2729 | virtual bool FMUL_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2730 | return false; | ||
| 2731 | } | ||
| 2732 | virtual bool FDIV_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2733 | return false; | ||
| 2734 | } | ||
| 2735 | virtual bool FADD_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2736 | return false; | ||
| 2737 | } | ||
| 2738 | virtual bool FSUB_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2739 | return false; | ||
| 2740 | } | ||
| 2741 | virtual bool FMAX_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2742 | return false; | ||
| 2743 | } | ||
| 2744 | virtual bool FMIN_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2745 | return false; | ||
| 2746 | } | ||
| 2747 | virtual bool FMAXNM_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2748 | return false; | ||
| 2749 | } | ||
| 2750 | virtual bool FMINNM_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2751 | return false; | ||
| 2752 | } | ||
| 2753 | virtual bool FNMUL_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) { | ||
| 2754 | return false; | ||
| 2755 | } | ||
| 2756 | |||
| 2757 | // Data Processing - FP and SIMD - Floating point conditional select | ||
| 2758 | virtual bool FCSEL_float(Imm<2> type, Vec Vm, Cond cond, Vec Vn, Vec Vd) { | ||
| 2759 | return false; | ||
| 2760 | } | ||
| 2761 | |||
| 2762 | // Data Processing - FP and SIMD - Floating point data processing three register | ||
| 2763 | virtual bool FMADD_float(Imm<2> type, Vec Vm, Vec Va, Vec Vn, Vec Vd) { | ||
| 2764 | return false; | ||
| 2765 | } | ||
| 2766 | virtual bool FMSUB_float(Imm<2> type, Vec Vm, Vec Va, Vec Vn, Vec Vd) { | ||
| 2767 | return false; | ||
| 2768 | } | ||
| 2769 | virtual bool FNMADD_float(Imm<2> type, Vec Vm, Vec Va, Vec Vn, Vec Vd) { | ||
| 2770 | return false; | ||
| 2771 | } | ||
| 2772 | virtual bool FNMSUB_float(Imm<2> type, Vec Vm, Vec Va, Vec Vn, Vec Vd) { | ||
| 2773 | return false; | ||
| 2774 | } | ||
| 2775 | }; | ||
| 2776 | |||
| 2777 | } // namespace Core | ||
diff --git a/src/core/core.cpp b/src/core/core.cpp index 229cb879c..b14f74976 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -36,6 +36,7 @@ | |||
| 36 | #include "core/hle/kernel/k_scheduler.h" | 36 | #include "core/hle/kernel/k_scheduler.h" |
| 37 | #include "core/hle/kernel/kernel.h" | 37 | #include "core/hle/kernel/kernel.h" |
| 38 | #include "core/hle/kernel/physical_core.h" | 38 | #include "core/hle/kernel/physical_core.h" |
| 39 | #include "core/hle/service/acc/profile_manager.h" | ||
| 39 | #include "core/hle/service/am/applets/applets.h" | 40 | #include "core/hle/service/am/applets/applets.h" |
| 40 | #include "core/hle/service/apm/apm_controller.h" | 41 | #include "core/hle/service/apm/apm_controller.h" |
| 41 | #include "core/hle/service/filesystem/filesystem.h" | 42 | #include "core/hle/service/filesystem/filesystem.h" |
| @@ -130,8 +131,8 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, | |||
| 130 | struct System::Impl { | 131 | struct System::Impl { |
| 131 | explicit Impl(System& system) | 132 | explicit Impl(System& system) |
| 132 | : kernel{system}, fs_controller{system}, memory{system}, hid_core{}, room_network{}, | 133 | : kernel{system}, fs_controller{system}, memory{system}, hid_core{}, room_network{}, |
| 133 | cpu_manager{system}, reporter{system}, applet_manager{system}, time_manager{system}, | 134 | cpu_manager{system}, reporter{system}, applet_manager{system}, profile_manager{}, |
| 134 | gpu_dirty_memory_write_manager{} { | 135 | time_manager{system}, gpu_dirty_memory_write_manager{} { |
| 135 | memory.SetGPUDirtyManagers(gpu_dirty_memory_write_manager); | 136 | memory.SetGPUDirtyManagers(gpu_dirty_memory_write_manager); |
| 136 | } | 137 | } |
| 137 | 138 | ||
| @@ -532,6 +533,7 @@ struct System::Impl { | |||
| 532 | 533 | ||
| 533 | /// Service State | 534 | /// Service State |
| 534 | Service::Glue::ARPManager arp_manager; | 535 | Service::Glue::ARPManager arp_manager; |
| 536 | Service::Account::ProfileManager profile_manager; | ||
| 535 | Service::Time::TimeManager time_manager; | 537 | Service::Time::TimeManager time_manager; |
| 536 | 538 | ||
| 537 | /// Service manager | 539 | /// Service manager |
| @@ -921,6 +923,14 @@ const Service::APM::Controller& System::GetAPMController() const { | |||
| 921 | return impl->apm_controller; | 923 | return impl->apm_controller; |
| 922 | } | 924 | } |
| 923 | 925 | ||
| 926 | Service::Account::ProfileManager& System::GetProfileManager() { | ||
| 927 | return impl->profile_manager; | ||
| 928 | } | ||
| 929 | |||
| 930 | const Service::Account::ProfileManager& System::GetProfileManager() const { | ||
| 931 | return impl->profile_manager; | ||
| 932 | } | ||
| 933 | |||
| 924 | Service::Time::TimeManager& System::GetTimeManager() { | 934 | Service::Time::TimeManager& System::GetTimeManager() { |
| 925 | return impl->time_manager; | 935 | return impl->time_manager; |
| 926 | } | 936 | } |
diff --git a/src/core/core.h b/src/core/core.h index 05a222f5c..473204db7 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -45,6 +45,10 @@ class Memory; | |||
| 45 | 45 | ||
| 46 | namespace Service { | 46 | namespace Service { |
| 47 | 47 | ||
| 48 | namespace Account { | ||
| 49 | class ProfileManager; | ||
| 50 | } // namespace Account | ||
| 51 | |||
| 48 | namespace AM::Applets { | 52 | namespace AM::Applets { |
| 49 | struct AppletFrontendSet; | 53 | struct AppletFrontendSet; |
| 50 | class AppletManager; | 54 | class AppletManager; |
| @@ -383,6 +387,9 @@ public: | |||
| 383 | [[nodiscard]] Service::APM::Controller& GetAPMController(); | 387 | [[nodiscard]] Service::APM::Controller& GetAPMController(); |
| 384 | [[nodiscard]] const Service::APM::Controller& GetAPMController() const; | 388 | [[nodiscard]] const Service::APM::Controller& GetAPMController() const; |
| 385 | 389 | ||
| 390 | [[nodiscard]] Service::Account::ProfileManager& GetProfileManager(); | ||
| 391 | [[nodiscard]] const Service::Account::ProfileManager& GetProfileManager() const; | ||
| 392 | |||
| 386 | [[nodiscard]] Service::Time::TimeManager& GetTimeManager(); | 393 | [[nodiscard]] Service::Time::TimeManager& GetTimeManager(); |
| 387 | [[nodiscard]] const Service::Time::TimeManager& GetTimeManager() const; | 394 | [[nodiscard]] const Service::Time::TimeManager& GetTimeManager() const; |
| 388 | 395 | ||
diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp index a4d060007..8d5d593e8 100644 --- a/src/core/file_sys/savedata_factory.cpp +++ b/src/core/file_sys/savedata_factory.cpp | |||
| @@ -12,8 +12,6 @@ | |||
| 12 | 12 | ||
| 13 | namespace FileSys { | 13 | namespace FileSys { |
| 14 | 14 | ||
| 15 | constexpr char SAVE_DATA_SIZE_FILENAME[] = ".yuzu_save_size"; | ||
| 16 | |||
| 17 | namespace { | 15 | namespace { |
| 18 | 16 | ||
| 19 | void PrintSaveDataAttributeWarnings(SaveDataAttribute meta) { | 17 | void PrintSaveDataAttributeWarnings(SaveDataAttribute meta) { |
| @@ -197,7 +195,7 @@ SaveDataSize SaveDataFactory::ReadSaveDataSize(SaveDataType type, u64 title_id, | |||
| 197 | GetFullPath(system, dir, SaveDataSpaceId::NandUser, type, title_id, user_id, 0); | 195 | GetFullPath(system, dir, SaveDataSpaceId::NandUser, type, title_id, user_id, 0); |
| 198 | const auto relative_dir = GetOrCreateDirectoryRelative(dir, path); | 196 | const auto relative_dir = GetOrCreateDirectoryRelative(dir, path); |
| 199 | 197 | ||
| 200 | const auto size_file = relative_dir->GetFile(SAVE_DATA_SIZE_FILENAME); | 198 | const auto size_file = relative_dir->GetFile(GetSaveDataSizeFileName()); |
| 201 | if (size_file == nullptr || size_file->GetSize() < sizeof(SaveDataSize)) { | 199 | if (size_file == nullptr || size_file->GetSize() < sizeof(SaveDataSize)) { |
| 202 | return {0, 0}; | 200 | return {0, 0}; |
| 203 | } | 201 | } |
| @@ -216,7 +214,7 @@ void SaveDataFactory::WriteSaveDataSize(SaveDataType type, u64 title_id, u128 us | |||
| 216 | GetFullPath(system, dir, SaveDataSpaceId::NandUser, type, title_id, user_id, 0); | 214 | GetFullPath(system, dir, SaveDataSpaceId::NandUser, type, title_id, user_id, 0); |
| 217 | const auto relative_dir = GetOrCreateDirectoryRelative(dir, path); | 215 | const auto relative_dir = GetOrCreateDirectoryRelative(dir, path); |
| 218 | 216 | ||
| 219 | const auto size_file = relative_dir->CreateFile(SAVE_DATA_SIZE_FILENAME); | 217 | const auto size_file = relative_dir->CreateFile(GetSaveDataSizeFileName()); |
| 220 | if (size_file == nullptr) { | 218 | if (size_file == nullptr) { |
| 221 | return; | 219 | return; |
| 222 | } | 220 | } |
diff --git a/src/core/file_sys/savedata_factory.h b/src/core/file_sys/savedata_factory.h index 45c7c81fb..e3a0f8cef 100644 --- a/src/core/file_sys/savedata_factory.h +++ b/src/core/file_sys/savedata_factory.h | |||
| @@ -83,6 +83,10 @@ struct SaveDataSize { | |||
| 83 | u64 journal; | 83 | u64 journal; |
| 84 | }; | 84 | }; |
| 85 | 85 | ||
| 86 | constexpr const char* GetSaveDataSizeFileName() { | ||
| 87 | return ".yuzu_save_size"; | ||
| 88 | } | ||
| 89 | |||
| 86 | /// File system interface to the SaveData archive | 90 | /// File system interface to the SaveData archive |
| 87 | class SaveDataFactory { | 91 | class SaveDataFactory { |
| 88 | public: | 92 | public: |
diff --git a/src/core/file_sys/vfs.cpp b/src/core/file_sys/vfs.cpp index 639842401..b7105c8ff 100644 --- a/src/core/file_sys/vfs.cpp +++ b/src/core/file_sys/vfs.cpp | |||
| @@ -201,8 +201,6 @@ std::string VfsFile::GetFullPath() const { | |||
| 201 | 201 | ||
| 202 | VirtualFile VfsDirectory::GetFileRelative(std::string_view path) const { | 202 | VirtualFile VfsDirectory::GetFileRelative(std::string_view path) const { |
| 203 | auto vec = Common::FS::SplitPathComponents(path); | 203 | auto vec = Common::FS::SplitPathComponents(path); |
| 204 | vec.erase(std::remove_if(vec.begin(), vec.end(), [](const auto& str) { return str.empty(); }), | ||
| 205 | vec.end()); | ||
| 206 | if (vec.empty()) { | 204 | if (vec.empty()) { |
| 207 | return nullptr; | 205 | return nullptr; |
| 208 | } | 206 | } |
| @@ -237,8 +235,6 @@ VirtualFile VfsDirectory::GetFileAbsolute(std::string_view path) const { | |||
| 237 | 235 | ||
| 238 | VirtualDir VfsDirectory::GetDirectoryRelative(std::string_view path) const { | 236 | VirtualDir VfsDirectory::GetDirectoryRelative(std::string_view path) const { |
| 239 | auto vec = Common::FS::SplitPathComponents(path); | 237 | auto vec = Common::FS::SplitPathComponents(path); |
| 240 | vec.erase(std::remove_if(vec.begin(), vec.end(), [](const auto& str) { return str.empty(); }), | ||
| 241 | vec.end()); | ||
| 242 | if (vec.empty()) { | 238 | if (vec.empty()) { |
| 243 | // TODO(DarkLordZach): Return this directory if path is '/' or similar. Can't currently | 239 | // TODO(DarkLordZach): Return this directory if path is '/' or similar. Can't currently |
| 244 | // because of const-ness | 240 | // because of const-ness |
| @@ -303,8 +299,6 @@ std::size_t VfsDirectory::GetSize() const { | |||
| 303 | 299 | ||
| 304 | VirtualFile VfsDirectory::CreateFileRelative(std::string_view path) { | 300 | VirtualFile VfsDirectory::CreateFileRelative(std::string_view path) { |
| 305 | auto vec = Common::FS::SplitPathComponents(path); | 301 | auto vec = Common::FS::SplitPathComponents(path); |
| 306 | vec.erase(std::remove_if(vec.begin(), vec.end(), [](const auto& str) { return str.empty(); }), | ||
| 307 | vec.end()); | ||
| 308 | if (vec.empty()) { | 302 | if (vec.empty()) { |
| 309 | return nullptr; | 303 | return nullptr; |
| 310 | } | 304 | } |
| @@ -334,8 +328,6 @@ VirtualFile VfsDirectory::CreateFileAbsolute(std::string_view path) { | |||
| 334 | 328 | ||
| 335 | VirtualDir VfsDirectory::CreateDirectoryRelative(std::string_view path) { | 329 | VirtualDir VfsDirectory::CreateDirectoryRelative(std::string_view path) { |
| 336 | auto vec = Common::FS::SplitPathComponents(path); | 330 | auto vec = Common::FS::SplitPathComponents(path); |
| 337 | vec.erase(std::remove_if(vec.begin(), vec.end(), [](const auto& str) { return str.empty(); }), | ||
| 338 | vec.end()); | ||
| 339 | if (vec.empty()) { | 331 | if (vec.empty()) { |
| 340 | return nullptr; | 332 | return nullptr; |
| 341 | } | 333 | } |
diff --git a/src/core/file_sys/vfs_real.cpp b/src/core/file_sys/vfs_real.cpp index 1c706e4d8..cd9b79786 100644 --- a/src/core/file_sys/vfs_real.cpp +++ b/src/core/file_sys/vfs_real.cpp | |||
| @@ -268,7 +268,7 @@ void RealVfsFilesystem::RemoveReferenceFromListLocked(FileReference& reference) | |||
| 268 | RealVfsFile::RealVfsFile(RealVfsFilesystem& base_, std::unique_ptr<FileReference> reference_, | 268 | RealVfsFile::RealVfsFile(RealVfsFilesystem& base_, std::unique_ptr<FileReference> reference_, |
| 269 | const std::string& path_, Mode perms_, std::optional<u64> size_) | 269 | const std::string& path_, Mode perms_, std::optional<u64> size_) |
| 270 | : base(base_), reference(std::move(reference_)), path(path_), | 270 | : base(base_), reference(std::move(reference_)), path(path_), |
| 271 | parent_path(FS::GetParentPath(path_)), path_components(FS::SplitPathComponents(path_)), | 271 | parent_path(FS::GetParentPath(path_)), path_components(FS::SplitPathComponentsCopy(path_)), |
| 272 | size(size_), perms(perms_) {} | 272 | size(size_), perms(perms_) {} |
| 273 | 273 | ||
| 274 | RealVfsFile::~RealVfsFile() { | 274 | RealVfsFile::~RealVfsFile() { |
| @@ -276,7 +276,7 @@ RealVfsFile::~RealVfsFile() { | |||
| 276 | } | 276 | } |
| 277 | 277 | ||
| 278 | std::string RealVfsFile::GetName() const { | 278 | std::string RealVfsFile::GetName() const { |
| 279 | return path_components.back(); | 279 | return path_components.empty() ? "" : std::string(path_components.back()); |
| 280 | } | 280 | } |
| 281 | 281 | ||
| 282 | std::size_t RealVfsFile::GetSize() const { | 282 | std::size_t RealVfsFile::GetSize() const { |
| @@ -375,7 +375,7 @@ std::vector<VirtualDir> RealVfsDirectory::IterateEntries<RealVfsDirectory, VfsDi | |||
| 375 | 375 | ||
| 376 | RealVfsDirectory::RealVfsDirectory(RealVfsFilesystem& base_, const std::string& path_, Mode perms_) | 376 | RealVfsDirectory::RealVfsDirectory(RealVfsFilesystem& base_, const std::string& path_, Mode perms_) |
| 377 | : base(base_), path(FS::RemoveTrailingSlash(path_)), parent_path(FS::GetParentPath(path)), | 377 | : base(base_), path(FS::RemoveTrailingSlash(path_)), parent_path(FS::GetParentPath(path)), |
| 378 | path_components(FS::SplitPathComponents(path)), perms(perms_) { | 378 | path_components(FS::SplitPathComponentsCopy(path)), perms(perms_) { |
| 379 | if (!FS::Exists(path) && True(perms & Mode::Write)) { | 379 | if (!FS::Exists(path) && True(perms & Mode::Write)) { |
| 380 | void(FS::CreateDirs(path)); | 380 | void(FS::CreateDirs(path)); |
| 381 | } | 381 | } |
| @@ -464,7 +464,7 @@ bool RealVfsDirectory::IsReadable() const { | |||
| 464 | } | 464 | } |
| 465 | 465 | ||
| 466 | std::string RealVfsDirectory::GetName() const { | 466 | std::string RealVfsDirectory::GetName() const { |
| 467 | return path_components.back(); | 467 | return path_components.empty() ? "" : std::string(path_components.back()); |
| 468 | } | 468 | } |
| 469 | 469 | ||
| 470 | VirtualDir RealVfsDirectory::GetParentDirectory() const { | 470 | VirtualDir RealVfsDirectory::GetParentDirectory() const { |
diff --git a/src/core/hid/input_interpreter.cpp b/src/core/hid/input_interpreter.cpp index a6bdd28f2..072f38a68 100644 --- a/src/core/hid/input_interpreter.cpp +++ b/src/core/hid/input_interpreter.cpp | |||
| @@ -20,6 +20,9 @@ InputInterpreter::InputInterpreter(Core::System& system) | |||
| 20 | InputInterpreter::~InputInterpreter() = default; | 20 | InputInterpreter::~InputInterpreter() = default; |
| 21 | 21 | ||
| 22 | void InputInterpreter::PollInput() { | 22 | void InputInterpreter::PollInput() { |
| 23 | if (npad == nullptr) { | ||
| 24 | return; | ||
| 25 | } | ||
| 23 | const auto button_state = npad->GetAndResetPressState(); | 26 | const auto button_state = npad->GetAndResetPressState(); |
| 24 | 27 | ||
| 25 | previous_index = current_index; | 28 | previous_index = current_index; |
diff --git a/src/core/hle/kernel/k_memory_manager.cpp b/src/core/hle/kernel/k_memory_manager.cpp index 0a973ec8c..d6bd27296 100644 --- a/src/core/hle/kernel/k_memory_manager.cpp +++ b/src/core/hle/kernel/k_memory_manager.cpp | |||
| @@ -421,8 +421,9 @@ Result KMemoryManager::AllocateForProcess(KPageGroup* out, size_t num_pages, u32 | |||
| 421 | } else { | 421 | } else { |
| 422 | // Set all the allocated memory. | 422 | // Set all the allocated memory. |
| 423 | for (const auto& block : *out) { | 423 | for (const auto& block : *out) { |
| 424 | std::memset(m_system.DeviceMemory().GetPointer<void>(block.GetAddress()), fill_pattern, | 424 | m_system.DeviceMemory().buffer.ClearBackingRegion(GetInteger(block.GetAddress()) - |
| 425 | block.GetSize()); | 425 | Core::DramMemoryMap::Base, |
| 426 | block.GetSize(), fill_pattern); | ||
| 426 | } | 427 | } |
| 427 | } | 428 | } |
| 428 | 429 | ||
diff --git a/src/core/hle/kernel/k_page_table_base.cpp b/src/core/hle/kernel/k_page_table_base.cpp index 4c416d809..423289145 100644 --- a/src/core/hle/kernel/k_page_table_base.cpp +++ b/src/core/hle/kernel/k_page_table_base.cpp | |||
| @@ -81,6 +81,11 @@ void InvalidateInstructionCache(KernelCore& kernel, AddressType addr, u64 size) | |||
| 81 | } | 81 | } |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | void ClearBackingRegion(Core::System& system, KPhysicalAddress addr, u64 size, u32 fill_value) { | ||
| 85 | system.DeviceMemory().buffer.ClearBackingRegion(GetInteger(addr) - Core::DramMemoryMap::Base, | ||
| 86 | size, fill_value); | ||
| 87 | } | ||
| 88 | |||
| 84 | template <typename AddressType> | 89 | template <typename AddressType> |
| 85 | Result InvalidateDataCache(AddressType addr, u64 size) { | 90 | Result InvalidateDataCache(AddressType addr, u64 size) { |
| 86 | R_SUCCEED(); | 91 | R_SUCCEED(); |
| @@ -1363,8 +1368,7 @@ Result KPageTableBase::MapInsecureMemory(KProcessAddress address, size_t size) { | |||
| 1363 | 1368 | ||
| 1364 | // Clear all the newly allocated pages. | 1369 | // Clear all the newly allocated pages. |
| 1365 | for (const auto& it : pg) { | 1370 | for (const auto& it : pg) { |
| 1366 | std::memset(GetHeapVirtualPointer(m_kernel, it.GetAddress()), | 1371 | ClearBackingRegion(m_system, it.GetAddress(), it.GetSize(), m_heap_fill_value); |
| 1367 | static_cast<u32>(m_heap_fill_value), it.GetSize()); | ||
| 1368 | } | 1372 | } |
| 1369 | 1373 | ||
| 1370 | // Lock the table. | 1374 | // Lock the table. |
| @@ -1570,8 +1574,7 @@ Result KPageTableBase::AllocateAndMapPagesImpl(PageLinkedList* page_list, KProce | |||
| 1570 | 1574 | ||
| 1571 | // Clear all pages. | 1575 | // Clear all pages. |
| 1572 | for (const auto& it : pg) { | 1576 | for (const auto& it : pg) { |
| 1573 | std::memset(GetHeapVirtualPointer(m_kernel, it.GetAddress()), | 1577 | ClearBackingRegion(m_system, it.GetAddress(), it.GetSize(), m_heap_fill_value); |
| 1574 | static_cast<u32>(m_heap_fill_value), it.GetSize()); | ||
| 1575 | } | 1578 | } |
| 1576 | 1579 | ||
| 1577 | // Map the pages. | 1580 | // Map the pages. |
| @@ -2159,8 +2162,7 @@ Result KPageTableBase::SetHeapSize(KProcessAddress* out, size_t size) { | |||
| 2159 | 2162 | ||
| 2160 | // Clear all the newly allocated pages. | 2163 | // Clear all the newly allocated pages. |
| 2161 | for (const auto& it : pg) { | 2164 | for (const auto& it : pg) { |
| 2162 | std::memset(GetHeapVirtualPointer(m_kernel, it.GetAddress()), m_heap_fill_value, | 2165 | ClearBackingRegion(m_system, it.GetAddress(), it.GetSize(), m_heap_fill_value); |
| 2163 | it.GetSize()); | ||
| 2164 | } | 2166 | } |
| 2165 | 2167 | ||
| 2166 | // Map the pages. | 2168 | // Map the pages. |
diff --git a/src/core/hle/kernel/k_server_session.cpp b/src/core/hle/kernel/k_server_session.cpp index ec6812d5a..e33a88e24 100644 --- a/src/core/hle/kernel/k_server_session.cpp +++ b/src/core/hle/kernel/k_server_session.cpp | |||
| @@ -467,8 +467,7 @@ Result KServerSession::ReceiveRequest(std::shared_ptr<Service::HLERequestContext | |||
| 467 | std::make_shared<Service::HLERequestContext>(m_kernel, memory, this, client_thread); | 467 | std::make_shared<Service::HLERequestContext>(m_kernel, memory, this, client_thread); |
| 468 | (*out_context)->SetSessionRequestManager(manager); | 468 | (*out_context)->SetSessionRequestManager(manager); |
| 469 | (*out_context) | 469 | (*out_context) |
| 470 | ->PopulateFromIncomingCommandBuffer(client_thread->GetOwnerProcess()->GetHandleTable(), | 470 | ->PopulateFromIncomingCommandBuffer(*client_thread->GetOwnerProcess(), cmd_buf); |
| 471 | cmd_buf); | ||
| 472 | } else { | 471 | } else { |
| 473 | KThread* server_thread = GetCurrentThreadPointer(m_kernel); | 472 | KThread* server_thread = GetCurrentThreadPointer(m_kernel); |
| 474 | KProcess& src_process = *client_thread->GetOwnerProcess(); | 473 | KProcess& src_process = *client_thread->GetOwnerProcess(); |
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 8cb05ca0b..e479dacde 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -135,7 +135,6 @@ struct KernelCore::Impl { | |||
| 135 | obj = nullptr; | 135 | obj = nullptr; |
| 136 | } | 136 | } |
| 137 | }; | 137 | }; |
| 138 | CleanupObject(hid_shared_mem); | ||
| 139 | CleanupObject(font_shared_mem); | 138 | CleanupObject(font_shared_mem); |
| 140 | CleanupObject(irs_shared_mem); | 139 | CleanupObject(irs_shared_mem); |
| 141 | CleanupObject(time_shared_mem); | 140 | CleanupObject(time_shared_mem); |
| @@ -744,22 +743,16 @@ struct KernelCore::Impl { | |||
| 744 | void InitializeHackSharedMemory(KernelCore& kernel) { | 743 | void InitializeHackSharedMemory(KernelCore& kernel) { |
| 745 | // Setup memory regions for emulated processes | 744 | // Setup memory regions for emulated processes |
| 746 | // TODO(bunnei): These should not be hardcoded regions initialized within the kernel | 745 | // TODO(bunnei): These should not be hardcoded regions initialized within the kernel |
| 747 | constexpr std::size_t hid_size{0x40000}; | ||
| 748 | constexpr std::size_t font_size{0x1100000}; | 746 | constexpr std::size_t font_size{0x1100000}; |
| 749 | constexpr std::size_t irs_size{0x8000}; | 747 | constexpr std::size_t irs_size{0x8000}; |
| 750 | constexpr std::size_t time_size{0x1000}; | 748 | constexpr std::size_t time_size{0x1000}; |
| 751 | constexpr std::size_t hidbus_size{0x1000}; | 749 | constexpr std::size_t hidbus_size{0x1000}; |
| 752 | 750 | ||
| 753 | hid_shared_mem = KSharedMemory::Create(system.Kernel()); | ||
| 754 | font_shared_mem = KSharedMemory::Create(system.Kernel()); | 751 | font_shared_mem = KSharedMemory::Create(system.Kernel()); |
| 755 | irs_shared_mem = KSharedMemory::Create(system.Kernel()); | 752 | irs_shared_mem = KSharedMemory::Create(system.Kernel()); |
| 756 | time_shared_mem = KSharedMemory::Create(system.Kernel()); | 753 | time_shared_mem = KSharedMemory::Create(system.Kernel()); |
| 757 | hidbus_shared_mem = KSharedMemory::Create(system.Kernel()); | 754 | hidbus_shared_mem = KSharedMemory::Create(system.Kernel()); |
| 758 | 755 | ||
| 759 | hid_shared_mem->Initialize(system.DeviceMemory(), nullptr, Svc::MemoryPermission::None, | ||
| 760 | Svc::MemoryPermission::Read, hid_size); | ||
| 761 | KSharedMemory::Register(kernel, hid_shared_mem); | ||
| 762 | |||
| 763 | font_shared_mem->Initialize(system.DeviceMemory(), nullptr, Svc::MemoryPermission::None, | 756 | font_shared_mem->Initialize(system.DeviceMemory(), nullptr, Svc::MemoryPermission::None, |
| 764 | Svc::MemoryPermission::Read, font_size); | 757 | Svc::MemoryPermission::Read, font_size); |
| 765 | KSharedMemory::Register(kernel, font_shared_mem); | 758 | KSharedMemory::Register(kernel, font_shared_mem); |
| @@ -1190,14 +1183,6 @@ const KSystemResource& KernelCore::GetSystemSystemResource() const { | |||
| 1190 | return *impl->sys_system_resource; | 1183 | return *impl->sys_system_resource; |
| 1191 | } | 1184 | } |
| 1192 | 1185 | ||
| 1193 | Kernel::KSharedMemory& KernelCore::GetHidSharedMem() { | ||
| 1194 | return *impl->hid_shared_mem; | ||
| 1195 | } | ||
| 1196 | |||
| 1197 | const Kernel::KSharedMemory& KernelCore::GetHidSharedMem() const { | ||
| 1198 | return *impl->hid_shared_mem; | ||
| 1199 | } | ||
| 1200 | |||
| 1201 | Kernel::KSharedMemory& KernelCore::GetFontSharedMem() { | 1186 | Kernel::KSharedMemory& KernelCore::GetFontSharedMem() { |
| 1202 | return *impl->font_shared_mem; | 1187 | return *impl->font_shared_mem; |
| 1203 | } | 1188 | } |
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 69b5bbd6c..78c88902c 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h | |||
| @@ -239,12 +239,6 @@ public: | |||
| 239 | /// Gets the system resource manager. | 239 | /// Gets the system resource manager. |
| 240 | const KSystemResource& GetSystemSystemResource() const; | 240 | const KSystemResource& GetSystemSystemResource() const; |
| 241 | 241 | ||
| 242 | /// Gets the shared memory object for HID services. | ||
| 243 | Kernel::KSharedMemory& GetHidSharedMem(); | ||
| 244 | |||
| 245 | /// Gets the shared memory object for HID services. | ||
| 246 | const Kernel::KSharedMemory& GetHidSharedMem() const; | ||
| 247 | |||
| 248 | /// Gets the shared memory object for font services. | 242 | /// Gets the shared memory object for font services. |
| 249 | Kernel::KSharedMemory& GetFontSharedMem(); | 243 | Kernel::KSharedMemory& GetFontSharedMem(); |
| 250 | 244 | ||
diff --git a/src/core/hle/kernel/physical_core.cpp b/src/core/hle/kernel/physical_core.cpp index 7fa8e2a85..0f45a3249 100644 --- a/src/core/hle/kernel/physical_core.cpp +++ b/src/core/hle/kernel/physical_core.cpp | |||
| @@ -139,7 +139,7 @@ void PhysicalCore::RunThread(Kernel::KThread* thread) { | |||
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | // Handle external interrupt sources. | 141 | // Handle external interrupt sources. |
| 142 | if (interrupt || !m_is_single_core) { | 142 | if (interrupt || m_is_single_core) { |
| 143 | return; | 143 | return; |
| 144 | } | 144 | } |
| 145 | } | 145 | } |
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index 508db7360..780f8c74d 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp | |||
| @@ -104,11 +104,7 @@ Result VfsDirectoryServiceWrapper::CreateDirectory(const std::string& path_) con | |||
| 104 | const auto components = Common::FS::SplitPathComponents(path); | 104 | const auto components = Common::FS::SplitPathComponents(path); |
| 105 | std::string relative_path; | 105 | std::string relative_path; |
| 106 | for (const auto& component : components) { | 106 | for (const auto& component : components) { |
| 107 | // Skip empty path components | 107 | relative_path = Common::FS::SanitizePath(fmt::format("{}/{}", relative_path, component)); |
| 108 | if (component.empty()) { | ||
| 109 | continue; | ||
| 110 | } | ||
| 111 | relative_path = Common::FS::SanitizePath(relative_path + '/' + component); | ||
| 112 | auto new_dir = backing->CreateSubdirectory(relative_path); | 108 | auto new_dir = backing->CreateSubdirectory(relative_path); |
| 113 | if (new_dir == nullptr) { | 109 | if (new_dir == nullptr) { |
| 114 | // TODO(DarkLordZach): Find a better error code for this | 110 | // TODO(DarkLordZach): Find a better error code for this |
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp index 126cd6ffd..b1310d6e4 100644 --- a/src/core/hle/service/filesystem/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp_srv.cpp | |||
| @@ -246,7 +246,13 @@ static void BuildEntryIndex(std::vector<FileSys::Entry>& entries, const std::vec | |||
| 246 | entries.reserve(entries.size() + new_data.size()); | 246 | entries.reserve(entries.size() + new_data.size()); |
| 247 | 247 | ||
| 248 | for (const auto& new_entry : new_data) { | 248 | for (const auto& new_entry : new_data) { |
| 249 | entries.emplace_back(new_entry->GetName(), type, | 249 | auto name = new_entry->GetName(); |
| 250 | |||
| 251 | if (type == FileSys::EntryType::File && name == FileSys::GetSaveDataSizeFileName()) { | ||
| 252 | continue; | ||
| 253 | } | ||
| 254 | |||
| 255 | entries.emplace_back(name, type, | ||
| 250 | type == FileSys::EntryType::Directory ? 0 : new_entry->GetSize()); | 256 | type == FileSys::EntryType::Directory ? 0 : new_entry->GetSize()); |
| 251 | } | 257 | } |
| 252 | } | 258 | } |
diff --git a/src/core/hle/service/hid/controllers/applet_resource.cpp b/src/core/hle/service/hid/controllers/applet_resource.cpp index ee60d8b44..c8e74c764 100644 --- a/src/core/hle/service/hid/controllers/applet_resource.cpp +++ b/src/core/hle/service/hid/controllers/applet_resource.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #include "core/core.h" | 4 | #include "core/core.h" |
| 5 | #include "core/hle/kernel/k_shared_memory.h" | 5 | #include "core/hle/kernel/k_shared_memory.h" |
| 6 | #include "core/hle/service/hid/controllers/applet_resource.h" | 6 | #include "core/hle/service/hid/controllers/applet_resource.h" |
| 7 | #include "core/hle/service/hid/controllers/shared_memory_format.h" | ||
| 7 | #include "core/hle/service/hid/errors.h" | 8 | #include "core/hle/service/hid/errors.h" |
| 8 | 9 | ||
| 9 | namespace Service::HID { | 10 | namespace Service::HID { |
| @@ -23,11 +24,24 @@ Result AppletResource::CreateAppletResource(u64 aruid) { | |||
| 23 | return ResultAruidAlreadyRegistered; | 24 | return ResultAruidAlreadyRegistered; |
| 24 | } | 25 | } |
| 25 | 26 | ||
| 26 | // TODO: Here shared memory is created for the process we don't quite emulate this part so | 27 | auto& shared_memory = shared_memory_holder[index]; |
| 27 | // obtain this pointer from system | 28 | if (!shared_memory.IsMapped()) { |
| 28 | auto& shared_memory = system.Kernel().GetHidSharedMem(); | 29 | const Result result = shared_memory.Initialize(system); |
| 30 | if (result.IsError()) { | ||
| 31 | return result; | ||
| 32 | } | ||
| 33 | if (shared_memory.GetAddress() == nullptr) { | ||
| 34 | shared_memory.Finalize(); | ||
| 35 | return ResultSharedMemoryNotInitialized; | ||
| 36 | } | ||
| 37 | } | ||
| 29 | 38 | ||
| 30 | data[index].shared_memory_handle = &shared_memory; | 39 | auto* shared_memory_format = shared_memory.GetAddress(); |
| 40 | if (shared_memory_format != nullptr) { | ||
| 41 | shared_memory_format->Initialize(); | ||
| 42 | } | ||
| 43 | |||
| 44 | data[index].shared_memory_format = shared_memory_format; | ||
| 31 | data[index].flag.is_assigned.Assign(true); | 45 | data[index].flag.is_assigned.Assign(true); |
| 32 | // TODO: InitializeSixAxisControllerConfig(false); | 46 | // TODO: InitializeSixAxisControllerConfig(false); |
| 33 | active_aruid = aruid; | 47 | active_aruid = aruid; |
| @@ -94,7 +108,7 @@ void AppletResource::UnregisterAppletResourceUserId(u64 aruid) { | |||
| 94 | 108 | ||
| 95 | if (index < AruidIndexMax) { | 109 | if (index < AruidIndexMax) { |
| 96 | if (data[index].flag.is_assigned) { | 110 | if (data[index].flag.is_assigned) { |
| 97 | data[index].shared_memory_handle = nullptr; | 111 | data[index].shared_memory_format = nullptr; |
| 98 | data[index].flag.is_assigned.Assign(false); | 112 | data[index].flag.is_assigned.Assign(false); |
| 99 | } | 113 | } |
| 100 | } | 114 | } |
| @@ -112,6 +126,19 @@ void AppletResource::UnregisterAppletResourceUserId(u64 aruid) { | |||
| 112 | } | 126 | } |
| 113 | } | 127 | } |
| 114 | 128 | ||
| 129 | void AppletResource::FreeAppletResourceId(u64 aruid) { | ||
| 130 | u64 index = GetIndexFromAruid(aruid); | ||
| 131 | if (index >= AruidIndexMax) { | ||
| 132 | return; | ||
| 133 | } | ||
| 134 | |||
| 135 | auto& aruid_data = data[index]; | ||
| 136 | if (aruid_data.flag.is_assigned) { | ||
| 137 | aruid_data.shared_memory_format = nullptr; | ||
| 138 | aruid_data.flag.is_assigned.Assign(false); | ||
| 139 | } | ||
| 140 | } | ||
| 141 | |||
| 115 | u64 AppletResource::GetActiveAruid() { | 142 | u64 AppletResource::GetActiveAruid() { |
| 116 | return active_aruid; | 143 | return active_aruid; |
| 117 | } | 144 | } |
| @@ -122,7 +149,18 @@ Result AppletResource::GetSharedMemoryHandle(Kernel::KSharedMemory** out_handle, | |||
| 122 | return ResultAruidNotRegistered; | 149 | return ResultAruidNotRegistered; |
| 123 | } | 150 | } |
| 124 | 151 | ||
| 125 | *out_handle = data[index].shared_memory_handle; | 152 | *out_handle = shared_memory_holder[index].GetHandle(); |
| 153 | return ResultSuccess; | ||
| 154 | } | ||
| 155 | |||
| 156 | Result AppletResource::GetSharedMemoryFormat(SharedMemoryFormat** out_shared_memory_format, | ||
| 157 | u64 aruid) { | ||
| 158 | u64 index = GetIndexFromAruid(aruid); | ||
| 159 | if (index >= AruidIndexMax) { | ||
| 160 | return ResultAruidNotRegistered; | ||
| 161 | } | ||
| 162 | |||
| 163 | *out_shared_memory_format = data[index].shared_memory_format; | ||
| 126 | return ResultSuccess; | 164 | return ResultSuccess; |
| 127 | } | 165 | } |
| 128 | 166 | ||
| @@ -196,4 +234,80 @@ void AppletResource::EnablePalmaBoostMode(u64 aruid, bool is_enabled) { | |||
| 196 | data[index].flag.enable_palma_boost_mode.Assign(is_enabled); | 234 | data[index].flag.enable_palma_boost_mode.Assign(is_enabled); |
| 197 | } | 235 | } |
| 198 | 236 | ||
| 237 | Result AppletResource::RegisterCoreAppletResource() { | ||
| 238 | if (ref_counter == std::numeric_limits<s32>::max() - 1) { | ||
| 239 | return ResultAppletResourceOverflow; | ||
| 240 | } | ||
| 241 | if (ref_counter == 0) { | ||
| 242 | const u64 index = GetIndexFromAruid(0); | ||
| 243 | if (index < AruidIndexMax) { | ||
| 244 | return ResultAruidAlreadyRegistered; | ||
| 245 | } | ||
| 246 | |||
| 247 | std::size_t data_index = AruidIndexMax; | ||
| 248 | for (std::size_t i = 0; i < AruidIndexMax; i++) { | ||
| 249 | if (!data[i].flag.is_initialized) { | ||
| 250 | data_index = i; | ||
| 251 | break; | ||
| 252 | } | ||
| 253 | } | ||
| 254 | |||
| 255 | if (data_index == AruidIndexMax) { | ||
| 256 | return ResultAruidNoAvailableEntries; | ||
| 257 | } | ||
| 258 | |||
| 259 | AruidData& aruid_data = data[data_index]; | ||
| 260 | |||
| 261 | aruid_data.aruid = 0; | ||
| 262 | aruid_data.flag.is_initialized.Assign(true); | ||
| 263 | aruid_data.flag.enable_pad_input.Assign(true); | ||
| 264 | aruid_data.flag.enable_six_axis_sensor.Assign(true); | ||
| 265 | aruid_data.flag.bit_18.Assign(true); | ||
| 266 | aruid_data.flag.enable_touchscreen.Assign(true); | ||
| 267 | |||
| 268 | data_index = AruidIndexMax; | ||
| 269 | for (std::size_t i = 0; i < AruidIndexMax; i++) { | ||
| 270 | if (registration_list.flag[i] == RegistrationStatus::Initialized) { | ||
| 271 | if (registration_list.aruid[i] != 0) { | ||
| 272 | continue; | ||
| 273 | } | ||
| 274 | data_index = i; | ||
| 275 | break; | ||
| 276 | } | ||
| 277 | if (registration_list.flag[i] == RegistrationStatus::None) { | ||
| 278 | data_index = i; | ||
| 279 | break; | ||
| 280 | } | ||
| 281 | } | ||
| 282 | |||
| 283 | Result result = ResultSuccess; | ||
| 284 | |||
| 285 | if (data_index == AruidIndexMax) { | ||
| 286 | result = CreateAppletResource(0); | ||
| 287 | } else { | ||
| 288 | registration_list.flag[data_index] = RegistrationStatus::Initialized; | ||
| 289 | registration_list.aruid[data_index] = 0; | ||
| 290 | } | ||
| 291 | |||
| 292 | if (result.IsError()) { | ||
| 293 | UnregisterAppletResourceUserId(0); | ||
| 294 | return result; | ||
| 295 | } | ||
| 296 | } | ||
| 297 | ref_counter++; | ||
| 298 | return ResultSuccess; | ||
| 299 | } | ||
| 300 | |||
| 301 | Result AppletResource::UnregisterCoreAppletResource() { | ||
| 302 | if (ref_counter == 0) { | ||
| 303 | return ResultAppletResourceNotInitialized; | ||
| 304 | } | ||
| 305 | |||
| 306 | if (--ref_counter == 0) { | ||
| 307 | UnregisterAppletResourceUserId(0); | ||
| 308 | } | ||
| 309 | |||
| 310 | return ResultSuccess; | ||
| 311 | } | ||
| 312 | |||
| 199 | } // namespace Service::HID | 313 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/controllers/applet_resource.h b/src/core/hle/service/hid/controllers/applet_resource.h index 3dcec2898..e7991f93a 100644 --- a/src/core/hle/service/hid/controllers/applet_resource.h +++ b/src/core/hle/service/hid/controllers/applet_resource.h | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include "common/bit_field.h" | 8 | #include "common/bit_field.h" |
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "core/hle/result.h" | 10 | #include "core/hle/result.h" |
| 11 | #include "core/hle/service/hid/controllers/shared_memory_holder.h" | ||
| 11 | 12 | ||
| 12 | namespace Core { | 13 | namespace Core { |
| 13 | class System; | 14 | class System; |
| @@ -18,6 +19,8 @@ class KSharedMemory; | |||
| 18 | } | 19 | } |
| 19 | 20 | ||
| 20 | namespace Service::HID { | 21 | namespace Service::HID { |
| 22 | struct SharedMemoryFormat; | ||
| 23 | |||
| 21 | class AppletResource { | 24 | class AppletResource { |
| 22 | public: | 25 | public: |
| 23 | explicit AppletResource(Core::System& system_); | 26 | explicit AppletResource(Core::System& system_); |
| @@ -28,8 +31,11 @@ public: | |||
| 28 | Result RegisterAppletResourceUserId(u64 aruid, bool enable_input); | 31 | Result RegisterAppletResourceUserId(u64 aruid, bool enable_input); |
| 29 | void UnregisterAppletResourceUserId(u64 aruid); | 32 | void UnregisterAppletResourceUserId(u64 aruid); |
| 30 | 33 | ||
| 34 | void FreeAppletResourceId(u64 aruid); | ||
| 35 | |||
| 31 | u64 GetActiveAruid(); | 36 | u64 GetActiveAruid(); |
| 32 | Result GetSharedMemoryHandle(Kernel::KSharedMemory** out_handle, u64 aruid); | 37 | Result GetSharedMemoryHandle(Kernel::KSharedMemory** out_handle, u64 aruid); |
| 38 | Result GetSharedMemoryFormat(SharedMemoryFormat** out_shared_memory_format, u64 aruid); | ||
| 33 | 39 | ||
| 34 | u64 GetIndexFromAruid(u64 aruid); | 40 | u64 GetIndexFromAruid(u64 aruid); |
| 35 | 41 | ||
| @@ -42,6 +48,9 @@ public: | |||
| 42 | void SetIsPalmaConnectable(u64 aruid, bool is_connectable); | 48 | void SetIsPalmaConnectable(u64 aruid, bool is_connectable); |
| 43 | void EnablePalmaBoostMode(u64 aruid, bool is_enabled); | 49 | void EnablePalmaBoostMode(u64 aruid, bool is_enabled); |
| 44 | 50 | ||
| 51 | Result RegisterCoreAppletResource(); | ||
| 52 | Result UnregisterCoreAppletResource(); | ||
| 53 | |||
| 45 | private: | 54 | private: |
| 46 | static constexpr std::size_t AruidIndexMax = 0x20; | 55 | static constexpr std::size_t AruidIndexMax = 0x20; |
| 47 | 56 | ||
| @@ -75,12 +84,14 @@ private: | |||
| 75 | struct AruidData { | 84 | struct AruidData { |
| 76 | DataStatusFlag flag{}; | 85 | DataStatusFlag flag{}; |
| 77 | u64 aruid{}; | 86 | u64 aruid{}; |
| 78 | Kernel::KSharedMemory* shared_memory_handle{nullptr}; | 87 | SharedMemoryFormat* shared_memory_format{nullptr}; |
| 79 | }; | 88 | }; |
| 80 | 89 | ||
| 81 | u64 active_aruid{}; | 90 | u64 active_aruid{}; |
| 82 | AruidRegisterList registration_list{}; | 91 | AruidRegisterList registration_list{}; |
| 83 | std::array<AruidData, AruidIndexMax> data{}; | 92 | std::array<AruidData, AruidIndexMax> data{}; |
| 93 | std::array<SharedMemoryHolder, AruidIndexMax> shared_memory_holder{}; | ||
| 94 | s32 ref_counter{}; | ||
| 84 | 95 | ||
| 85 | Core::System& system; | 96 | Core::System& system; |
| 86 | }; | 97 | }; |
diff --git a/src/core/hle/service/hid/controllers/console_six_axis.cpp b/src/core/hle/service/hid/controllers/console_six_axis.cpp index b2bf1d78d..3961d2b5f 100644 --- a/src/core/hle/service/hid/controllers/console_six_axis.cpp +++ b/src/core/hle/service/hid/controllers/console_six_axis.cpp | |||
| @@ -1,23 +1,18 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/core.h" | ||
| 5 | #include "core/core_timing.h" | 4 | #include "core/core_timing.h" |
| 6 | #include "core/hid/emulated_console.h" | 5 | #include "core/hid/emulated_console.h" |
| 7 | #include "core/hid/hid_core.h" | 6 | #include "core/hid/hid_core.h" |
| 8 | #include "core/hle/service/hid/controllers/console_six_axis.h" | 7 | #include "core/hle/service/hid/controllers/console_six_axis.h" |
| 9 | #include "core/memory.h" | 8 | #include "core/hle/service/hid/controllers/shared_memory_format.h" |
| 10 | 9 | ||
| 11 | namespace Service::HID { | 10 | namespace Service::HID { |
| 12 | constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3C200; | ||
| 13 | 11 | ||
| 14 | ConsoleSixAxis::ConsoleSixAxis(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_) | 12 | ConsoleSixAxis::ConsoleSixAxis(Core::HID::HIDCore& hid_core_, |
| 15 | : ControllerBase{hid_core_} { | 13 | ConsoleSixAxisSensorSharedMemoryFormat& console_shared_memory) |
| 14 | : ControllerBase{hid_core_}, shared_memory{console_shared_memory} { | ||
| 16 | console = hid_core.GetEmulatedConsole(); | 15 | console = hid_core.GetEmulatedConsole(); |
| 17 | static_assert(SHARED_MEMORY_OFFSET + sizeof(ConsoleSharedMemory) < shared_memory_size, | ||
| 18 | "ConsoleSharedMemory is bigger than the shared memory"); | ||
| 19 | shared_memory = std::construct_at( | ||
| 20 | reinterpret_cast<ConsoleSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET)); | ||
| 21 | } | 16 | } |
| 22 | 17 | ||
| 23 | ConsoleSixAxis::~ConsoleSixAxis() = default; | 18 | ConsoleSixAxis::~ConsoleSixAxis() = default; |
| @@ -33,10 +28,10 @@ void ConsoleSixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing) { | |||
| 33 | 28 | ||
| 34 | const auto motion_status = console->GetMotion(); | 29 | const auto motion_status = console->GetMotion(); |
| 35 | 30 | ||
| 36 | shared_memory->sampling_number++; | 31 | shared_memory.sampling_number++; |
| 37 | shared_memory->is_seven_six_axis_sensor_at_rest = motion_status.is_at_rest; | 32 | shared_memory.is_seven_six_axis_sensor_at_rest = motion_status.is_at_rest; |
| 38 | shared_memory->verticalization_error = motion_status.verticalization_error; | 33 | shared_memory.verticalization_error = motion_status.verticalization_error; |
| 39 | shared_memory->gyro_bias = motion_status.gyro_bias; | 34 | shared_memory.gyro_bias = motion_status.gyro_bias; |
| 40 | } | 35 | } |
| 41 | 36 | ||
| 42 | } // namespace Service::HID | 37 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/controllers/console_six_axis.h b/src/core/hle/service/hid/controllers/console_six_axis.h index 5b7c6a29a..3d1c9ce23 100644 --- a/src/core/hle/service/hid/controllers/console_six_axis.h +++ b/src/core/hle/service/hid/controllers/console_six_axis.h | |||
| @@ -3,7 +3,6 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "common/vector_math.h" | ||
| 7 | #include "core/hle/service/hid/controllers/controller_base.h" | 6 | #include "core/hle/service/hid/controllers/controller_base.h" |
| 8 | 7 | ||
| 9 | namespace Core::HID { | 8 | namespace Core::HID { |
| @@ -11,9 +10,12 @@ class EmulatedConsole; | |||
| 11 | } // namespace Core::HID | 10 | } // namespace Core::HID |
| 12 | 11 | ||
| 13 | namespace Service::HID { | 12 | namespace Service::HID { |
| 13 | struct ConsoleSixAxisSensorSharedMemoryFormat; | ||
| 14 | |||
| 14 | class ConsoleSixAxis final : public ControllerBase { | 15 | class ConsoleSixAxis final : public ControllerBase { |
| 15 | public: | 16 | public: |
| 16 | explicit ConsoleSixAxis(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_); | 17 | explicit ConsoleSixAxis(Core::HID::HIDCore& hid_core_, |
| 18 | ConsoleSixAxisSensorSharedMemoryFormat& console_shared_memory); | ||
| 17 | ~ConsoleSixAxis() override; | 19 | ~ConsoleSixAxis() override; |
| 18 | 20 | ||
| 19 | // Called when the controller is initialized | 21 | // Called when the controller is initialized |
| @@ -26,18 +28,7 @@ public: | |||
| 26 | void OnUpdate(const Core::Timing::CoreTiming& core_timing) override; | 28 | void OnUpdate(const Core::Timing::CoreTiming& core_timing) override; |
| 27 | 29 | ||
| 28 | private: | 30 | private: |
| 29 | // This is nn::hid::detail::ConsoleSixAxisSensorSharedMemoryFormat | 31 | ConsoleSixAxisSensorSharedMemoryFormat& shared_memory; |
| 30 | struct ConsoleSharedMemory { | ||
| 31 | u64 sampling_number{}; | ||
| 32 | bool is_seven_six_axis_sensor_at_rest{}; | ||
| 33 | INSERT_PADDING_BYTES(3); // padding | ||
| 34 | f32 verticalization_error{}; | ||
| 35 | Common::Vec3f gyro_bias{}; | ||
| 36 | INSERT_PADDING_BYTES(4); // padding | ||
| 37 | }; | ||
| 38 | static_assert(sizeof(ConsoleSharedMemory) == 0x20, "ConsoleSharedMemory is an invalid size"); | ||
| 39 | |||
| 40 | ConsoleSharedMemory* shared_memory = nullptr; | ||
| 41 | Core::HID::EmulatedConsole* console = nullptr; | 32 | Core::HID::EmulatedConsole* console = nullptr; |
| 42 | }; | 33 | }; |
| 43 | } // namespace Service::HID | 34 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/controllers/controller_base.h b/src/core/hle/service/hid/controllers/controller_base.h index 9a44ee41e..4326c7821 100644 --- a/src/core/hle/service/hid/controllers/controller_base.h +++ b/src/core/hle/service/hid/controllers/controller_base.h | |||
| @@ -39,9 +39,6 @@ public: | |||
| 39 | 39 | ||
| 40 | bool IsControllerActivated() const; | 40 | bool IsControllerActivated() const; |
| 41 | 41 | ||
| 42 | static const std::size_t hid_entry_count = 17; | ||
| 43 | static const std::size_t shared_memory_size = 0x40000; | ||
| 44 | |||
| 45 | protected: | 42 | protected: |
| 46 | bool is_activated{false}; | 43 | bool is_activated{false}; |
| 47 | 44 | ||
diff --git a/src/core/hle/service/hid/controllers/debug_pad.cpp b/src/core/hle/service/hid/controllers/debug_pad.cpp index 9de19ebfc..7d2370b4f 100644 --- a/src/core/hle/service/hid/controllers/debug_pad.cpp +++ b/src/core/hle/service/hid/controllers/debug_pad.cpp | |||
| @@ -1,24 +1,19 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include <cstring> | ||
| 5 | #include "common/common_types.h" | ||
| 6 | #include "common/settings.h" | 4 | #include "common/settings.h" |
| 7 | #include "core/core_timing.h" | 5 | #include "core/core_timing.h" |
| 8 | #include "core/hid/emulated_controller.h" | 6 | #include "core/hid/emulated_controller.h" |
| 9 | #include "core/hid/hid_core.h" | 7 | #include "core/hid/hid_core.h" |
| 10 | #include "core/hid/hid_types.h" | 8 | #include "core/hid/hid_types.h" |
| 11 | #include "core/hle/service/hid/controllers/debug_pad.h" | 9 | #include "core/hle/service/hid/controllers/debug_pad.h" |
| 10 | #include "core/hle/service/hid/controllers/shared_memory_format.h" | ||
| 12 | 11 | ||
| 13 | namespace Service::HID { | 12 | namespace Service::HID { |
| 14 | constexpr std::size_t SHARED_MEMORY_OFFSET = 0x00000; | 13 | |
| 15 | 14 | DebugPad::DebugPad(Core::HID::HIDCore& hid_core_, | |
| 16 | DebugPad::DebugPad(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_) | 15 | DebugPadSharedMemoryFormat& debug_pad_shared_memory) |
| 17 | : ControllerBase{hid_core_} { | 16 | : ControllerBase{hid_core_}, shared_memory{debug_pad_shared_memory} { |
| 18 | static_assert(SHARED_MEMORY_OFFSET + sizeof(DebugPadSharedMemory) < shared_memory_size, | ||
| 19 | "DebugPadSharedMemory is bigger than the shared memory"); | ||
| 20 | shared_memory = std::construct_at( | ||
| 21 | reinterpret_cast<DebugPadSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET)); | ||
| 22 | controller = hid_core.GetEmulatedController(Core::HID::NpadIdType::Other); | 17 | controller = hid_core.GetEmulatedController(Core::HID::NpadIdType::Other); |
| 23 | } | 18 | } |
| 24 | 19 | ||
| @@ -30,12 +25,12 @@ void DebugPad::OnRelease() {} | |||
| 30 | 25 | ||
| 31 | void DebugPad::OnUpdate(const Core::Timing::CoreTiming& core_timing) { | 26 | void DebugPad::OnUpdate(const Core::Timing::CoreTiming& core_timing) { |
| 32 | if (!IsControllerActivated()) { | 27 | if (!IsControllerActivated()) { |
| 33 | shared_memory->debug_pad_lifo.buffer_count = 0; | 28 | shared_memory.debug_pad_lifo.buffer_count = 0; |
| 34 | shared_memory->debug_pad_lifo.buffer_tail = 0; | 29 | shared_memory.debug_pad_lifo.buffer_tail = 0; |
| 35 | return; | 30 | return; |
| 36 | } | 31 | } |
| 37 | 32 | ||
| 38 | const auto& last_entry = shared_memory->debug_pad_lifo.ReadCurrentEntry().state; | 33 | const auto& last_entry = shared_memory.debug_pad_lifo.ReadCurrentEntry().state; |
| 39 | next_state.sampling_number = last_entry.sampling_number + 1; | 34 | next_state.sampling_number = last_entry.sampling_number + 1; |
| 40 | 35 | ||
| 41 | if (Settings::values.debug_pad_enabled) { | 36 | if (Settings::values.debug_pad_enabled) { |
| @@ -49,7 +44,7 @@ void DebugPad::OnUpdate(const Core::Timing::CoreTiming& core_timing) { | |||
| 49 | next_state.r_stick = stick_state.right; | 44 | next_state.r_stick = stick_state.right; |
| 50 | } | 45 | } |
| 51 | 46 | ||
| 52 | shared_memory->debug_pad_lifo.WriteNextEntry(next_state); | 47 | shared_memory.debug_pad_lifo.WriteNextEntry(next_state); |
| 53 | } | 48 | } |
| 54 | 49 | ||
| 55 | } // namespace Service::HID | 50 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/controllers/debug_pad.h b/src/core/hle/service/hid/controllers/debug_pad.h index 5566dba77..8ab29eca8 100644 --- a/src/core/hle/service/hid/controllers/debug_pad.h +++ b/src/core/hle/service/hid/controllers/debug_pad.h | |||
| @@ -3,21 +3,24 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "common/bit_field.h" | ||
| 7 | #include "common/common_types.h" | ||
| 8 | #include "core/hle/service/hid/controllers/controller_base.h" | 6 | #include "core/hle/service/hid/controllers/controller_base.h" |
| 9 | #include "core/hle/service/hid/ring_lifo.h" | 7 | #include "core/hle/service/hid/controllers/types/debug_pad_types.h" |
| 10 | 8 | ||
| 11 | namespace Core::HID { | 9 | namespace Core::HID { |
| 12 | class EmulatedController; | 10 | class HIDCore; |
| 13 | struct DebugPadButton; | 11 | } |
| 14 | struct AnalogStickState; | 12 | |
| 15 | } // namespace Core::HID | 13 | namespace Core::Timing { |
| 14 | class CoreTiming; | ||
| 15 | } | ||
| 16 | 16 | ||
| 17 | namespace Service::HID { | 17 | namespace Service::HID { |
| 18 | struct DebugPadSharedMemoryFormat; | ||
| 19 | |||
| 18 | class DebugPad final : public ControllerBase { | 20 | class DebugPad final : public ControllerBase { |
| 19 | public: | 21 | public: |
| 20 | explicit DebugPad(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_); | 22 | explicit DebugPad(Core::HID::HIDCore& hid_core_, |
| 23 | DebugPadSharedMemoryFormat& debug_pad_shared_memory); | ||
| 21 | ~DebugPad() override; | 24 | ~DebugPad() override; |
| 22 | 25 | ||
| 23 | // Called when the controller is initialized | 26 | // Called when the controller is initialized |
| @@ -30,35 +33,8 @@ public: | |||
| 30 | void OnUpdate(const Core::Timing::CoreTiming& core_timing) override; | 33 | void OnUpdate(const Core::Timing::CoreTiming& core_timing) override; |
| 31 | 34 | ||
| 32 | private: | 35 | private: |
| 33 | // This is nn::hid::DebugPadAttribute | ||
| 34 | struct DebugPadAttribute { | ||
| 35 | union { | ||
| 36 | u32 raw{}; | ||
| 37 | BitField<0, 1, u32> connected; | ||
| 38 | }; | ||
| 39 | }; | ||
| 40 | static_assert(sizeof(DebugPadAttribute) == 0x4, "DebugPadAttribute is an invalid size"); | ||
| 41 | |||
| 42 | // This is nn::hid::DebugPadState | ||
| 43 | struct DebugPadState { | ||
| 44 | s64 sampling_number{}; | ||
| 45 | DebugPadAttribute attribute{}; | ||
| 46 | Core::HID::DebugPadButton pad_state{}; | ||
| 47 | Core::HID::AnalogStickState r_stick{}; | ||
| 48 | Core::HID::AnalogStickState l_stick{}; | ||
| 49 | }; | ||
| 50 | static_assert(sizeof(DebugPadState) == 0x20, "DebugPadState is an invalid state"); | ||
| 51 | |||
| 52 | struct DebugPadSharedMemory { | ||
| 53 | // This is nn::hid::detail::DebugPadLifo | ||
| 54 | Lifo<DebugPadState, hid_entry_count> debug_pad_lifo{}; | ||
| 55 | static_assert(sizeof(debug_pad_lifo) == 0x2C8, "debug_pad_lifo is an invalid size"); | ||
| 56 | INSERT_PADDING_WORDS(0x4E); | ||
| 57 | }; | ||
| 58 | static_assert(sizeof(DebugPadSharedMemory) == 0x400, "DebugPadSharedMemory is an invalid size"); | ||
| 59 | |||
| 60 | DebugPadState next_state{}; | 36 | DebugPadState next_state{}; |
| 61 | DebugPadSharedMemory* shared_memory = nullptr; | 37 | DebugPadSharedMemoryFormat& shared_memory; |
| 62 | Core::HID::EmulatedController* controller = nullptr; | 38 | Core::HID::EmulatedController* controller = nullptr; |
| 63 | }; | 39 | }; |
| 64 | } // namespace Service::HID | 40 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/controllers/gesture.cpp b/src/core/hle/service/hid/controllers/gesture.cpp index 59b2ec73c..f658005f6 100644 --- a/src/core/hle/service/hid/controllers/gesture.cpp +++ b/src/core/hle/service/hid/controllers/gesture.cpp | |||
| @@ -1,17 +1,15 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "common/logging/log.h" | ||
| 5 | #include "common/math_util.h" | 4 | #include "common/math_util.h" |
| 6 | #include "common/settings.h" | 5 | #include "common/settings.h" |
| 7 | #include "core/core_timing.h" | ||
| 8 | #include "core/frontend/emu_window.h" | 6 | #include "core/frontend/emu_window.h" |
| 7 | #include "core/hid/emulated_console.h" | ||
| 9 | #include "core/hid/hid_core.h" | 8 | #include "core/hid/hid_core.h" |
| 10 | #include "core/hle/service/hid/controllers/gesture.h" | 9 | #include "core/hle/service/hid/controllers/gesture.h" |
| 10 | #include "core/hle/service/hid/controllers/shared_memory_format.h" | ||
| 11 | 11 | ||
| 12 | namespace Service::HID { | 12 | namespace Service::HID { |
| 13 | constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3BA00; | ||
| 14 | |||
| 15 | // HW is around 700, value is set to 400 to make it easier to trigger with mouse | 13 | // HW is around 700, value is set to 400 to make it easier to trigger with mouse |
| 16 | constexpr f32 swipe_threshold = 400.0f; // Threshold in pixels/s | 14 | constexpr f32 swipe_threshold = 400.0f; // Threshold in pixels/s |
| 17 | constexpr f32 angle_threshold = 0.015f; // Threshold in radians | 15 | constexpr f32 angle_threshold = 0.015f; // Threshold in radians |
| @@ -23,19 +21,15 @@ constexpr f32 Square(s32 num) { | |||
| 23 | return static_cast<f32>(num * num); | 21 | return static_cast<f32>(num * num); |
| 24 | } | 22 | } |
| 25 | 23 | ||
| 26 | Gesture::Gesture(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_) | 24 | Gesture::Gesture(Core::HID::HIDCore& hid_core_, GestureSharedMemoryFormat& gesture_shared_memory) |
| 27 | : ControllerBase(hid_core_) { | 25 | : ControllerBase(hid_core_), shared_memory{gesture_shared_memory} { |
| 28 | static_assert(SHARED_MEMORY_OFFSET + sizeof(GestureSharedMemory) < shared_memory_size, | ||
| 29 | "GestureSharedMemory is bigger than the shared memory"); | ||
| 30 | shared_memory = std::construct_at( | ||
| 31 | reinterpret_cast<GestureSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET)); | ||
| 32 | console = hid_core.GetEmulatedConsole(); | 26 | console = hid_core.GetEmulatedConsole(); |
| 33 | } | 27 | } |
| 34 | Gesture::~Gesture() = default; | 28 | Gesture::~Gesture() = default; |
| 35 | 29 | ||
| 36 | void Gesture::OnInit() { | 30 | void Gesture::OnInit() { |
| 37 | shared_memory->gesture_lifo.buffer_count = 0; | 31 | shared_memory.gesture_lifo.buffer_count = 0; |
| 38 | shared_memory->gesture_lifo.buffer_tail = 0; | 32 | shared_memory.gesture_lifo.buffer_tail = 0; |
| 39 | force_update = true; | 33 | force_update = true; |
| 40 | } | 34 | } |
| 41 | 35 | ||
| @@ -43,8 +37,8 @@ void Gesture::OnRelease() {} | |||
| 43 | 37 | ||
| 44 | void Gesture::OnUpdate(const Core::Timing::CoreTiming& core_timing) { | 38 | void Gesture::OnUpdate(const Core::Timing::CoreTiming& core_timing) { |
| 45 | if (!IsControllerActivated()) { | 39 | if (!IsControllerActivated()) { |
| 46 | shared_memory->gesture_lifo.buffer_count = 0; | 40 | shared_memory.gesture_lifo.buffer_count = 0; |
| 47 | shared_memory->gesture_lifo.buffer_tail = 0; | 41 | shared_memory.gesture_lifo.buffer_tail = 0; |
| 48 | return; | 42 | return; |
| 49 | } | 43 | } |
| 50 | 44 | ||
| @@ -52,7 +46,7 @@ void Gesture::OnUpdate(const Core::Timing::CoreTiming& core_timing) { | |||
| 52 | 46 | ||
| 53 | GestureProperties gesture = GetGestureProperties(); | 47 | GestureProperties gesture = GetGestureProperties(); |
| 54 | f32 time_difference = | 48 | f32 time_difference = |
| 55 | static_cast<f32>(shared_memory->gesture_lifo.timestamp - last_update_timestamp) / | 49 | static_cast<f32>(shared_memory.gesture_lifo.timestamp - last_update_timestamp) / |
| 56 | (1000 * 1000 * 1000); | 50 | (1000 * 1000 * 1000); |
| 57 | 51 | ||
| 58 | // Only update if necessary | 52 | // Only update if necessary |
| @@ -60,7 +54,7 @@ void Gesture::OnUpdate(const Core::Timing::CoreTiming& core_timing) { | |||
| 60 | return; | 54 | return; |
| 61 | } | 55 | } |
| 62 | 56 | ||
| 63 | last_update_timestamp = shared_memory->gesture_lifo.timestamp; | 57 | last_update_timestamp = shared_memory.gesture_lifo.timestamp; |
| 64 | UpdateGestureSharedMemory(gesture, time_difference); | 58 | UpdateGestureSharedMemory(gesture, time_difference); |
| 65 | } | 59 | } |
| 66 | 60 | ||
| @@ -103,7 +97,7 @@ void Gesture::UpdateGestureSharedMemory(GestureProperties& gesture, f32 time_dif | |||
| 103 | GestureType type = GestureType::Idle; | 97 | GestureType type = GestureType::Idle; |
| 104 | GestureAttribute attributes{}; | 98 | GestureAttribute attributes{}; |
| 105 | 99 | ||
| 106 | const auto& last_entry = shared_memory->gesture_lifo.ReadCurrentEntry().state; | 100 | const auto& last_entry = shared_memory.gesture_lifo.ReadCurrentEntry().state; |
| 107 | 101 | ||
| 108 | // Reset next state to default | 102 | // Reset next state to default |
| 109 | next_state.sampling_number = last_entry.sampling_number + 1; | 103 | next_state.sampling_number = last_entry.sampling_number + 1; |
| @@ -133,7 +127,7 @@ void Gesture::UpdateGestureSharedMemory(GestureProperties& gesture, f32 time_dif | |||
| 133 | next_state.points = gesture.points; | 127 | next_state.points = gesture.points; |
| 134 | last_gesture = gesture; | 128 | last_gesture = gesture; |
| 135 | 129 | ||
| 136 | shared_memory->gesture_lifo.WriteNextEntry(next_state); | 130 | shared_memory.gesture_lifo.WriteNextEntry(next_state); |
| 137 | } | 131 | } |
| 138 | 132 | ||
| 139 | void Gesture::NewGesture(GestureProperties& gesture, GestureType& type, | 133 | void Gesture::NewGesture(GestureProperties& gesture, GestureType& type, |
| @@ -305,11 +299,11 @@ void Gesture::SetSwipeEvent(GestureProperties& gesture, GestureProperties& last_ | |||
| 305 | next_state.direction = GestureDirection::Up; | 299 | next_state.direction = GestureDirection::Up; |
| 306 | } | 300 | } |
| 307 | 301 | ||
| 308 | const Gesture::GestureState& Gesture::GetLastGestureEntry() const { | 302 | const GestureState& Gesture::GetLastGestureEntry() const { |
| 309 | return shared_memory->gesture_lifo.ReadCurrentEntry().state; | 303 | return shared_memory.gesture_lifo.ReadCurrentEntry().state; |
| 310 | } | 304 | } |
| 311 | 305 | ||
| 312 | Gesture::GestureProperties Gesture::GetGestureProperties() { | 306 | GestureProperties Gesture::GetGestureProperties() { |
| 313 | GestureProperties gesture; | 307 | GestureProperties gesture; |
| 314 | std::array<Core::HID::TouchFinger, MAX_POINTS> active_fingers; | 308 | std::array<Core::HID::TouchFinger, MAX_POINTS> active_fingers; |
| 315 | const auto end_iter = std::copy_if(fingers.begin(), fingers.end(), active_fingers.begin(), | 309 | const auto end_iter = std::copy_if(fingers.begin(), fingers.end(), active_fingers.begin(), |
diff --git a/src/core/hle/service/hid/controllers/gesture.h b/src/core/hle/service/hid/controllers/gesture.h index 4c6f8ee07..41fdfcd03 100644 --- a/src/core/hle/service/hid/controllers/gesture.h +++ b/src/core/hle/service/hid/controllers/gesture.h | |||
| @@ -4,17 +4,22 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <array> | 6 | #include <array> |
| 7 | #include "common/bit_field.h" | 7 | |
| 8 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 9 | #include "common/point.h" | ||
| 10 | #include "core/hid/emulated_console.h" | ||
| 11 | #include "core/hle/service/hid/controllers/controller_base.h" | 9 | #include "core/hle/service/hid/controllers/controller_base.h" |
| 12 | #include "core/hle/service/hid/ring_lifo.h" | 10 | #include "core/hle/service/hid/controllers/types/touch_types.h" |
| 11 | |||
| 12 | namespace Core::HID { | ||
| 13 | class EmulatedConsole; | ||
| 14 | } | ||
| 13 | 15 | ||
| 14 | namespace Service::HID { | 16 | namespace Service::HID { |
| 17 | struct GestureSharedMemoryFormat; | ||
| 18 | |||
| 15 | class Gesture final : public ControllerBase { | 19 | class Gesture final : public ControllerBase { |
| 16 | public: | 20 | public: |
| 17 | explicit Gesture(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_); | 21 | explicit Gesture(Core::HID::HIDCore& hid_core_, |
| 22 | GestureSharedMemoryFormat& gesture_shared_memory); | ||
| 18 | ~Gesture() override; | 23 | ~Gesture() override; |
| 19 | 24 | ||
| 20 | // Called when the controller is initialized | 25 | // Called when the controller is initialized |
| @@ -27,79 +32,6 @@ public: | |||
| 27 | void OnUpdate(const Core::Timing::CoreTiming& core_timing) override; | 32 | void OnUpdate(const Core::Timing::CoreTiming& core_timing) override; |
| 28 | 33 | ||
| 29 | private: | 34 | private: |
| 30 | static constexpr size_t MAX_FINGERS = 16; | ||
| 31 | static constexpr size_t MAX_POINTS = 4; | ||
| 32 | |||
| 33 | // This is nn::hid::GestureType | ||
| 34 | enum class GestureType : u32 { | ||
| 35 | Idle, // Nothing touching the screen | ||
| 36 | Complete, // Set at the end of a touch event | ||
| 37 | Cancel, // Set when the number of fingers change | ||
| 38 | Touch, // A finger just touched the screen | ||
| 39 | Press, // Set if last type is touch and the finger hasn't moved | ||
| 40 | Tap, // Fast press then release | ||
| 41 | Pan, // All points moving together across the screen | ||
| 42 | Swipe, // Fast press movement and release of a single point | ||
| 43 | Pinch, // All points moving away/closer to the midpoint | ||
| 44 | Rotate, // All points rotating from the midpoint | ||
| 45 | }; | ||
| 46 | |||
| 47 | // This is nn::hid::GestureDirection | ||
| 48 | enum class GestureDirection : u32 { | ||
| 49 | None, | ||
| 50 | Left, | ||
| 51 | Up, | ||
| 52 | Right, | ||
| 53 | Down, | ||
| 54 | }; | ||
| 55 | |||
| 56 | // This is nn::hid::GestureAttribute | ||
| 57 | struct GestureAttribute { | ||
| 58 | union { | ||
| 59 | u32 raw{}; | ||
| 60 | |||
| 61 | BitField<4, 1, u32> is_new_touch; | ||
| 62 | BitField<8, 1, u32> is_double_tap; | ||
| 63 | }; | ||
| 64 | }; | ||
| 65 | static_assert(sizeof(GestureAttribute) == 4, "GestureAttribute is an invalid size"); | ||
| 66 | |||
| 67 | // This is nn::hid::GestureState | ||
| 68 | struct GestureState { | ||
| 69 | s64 sampling_number{}; | ||
| 70 | s64 detection_count{}; | ||
| 71 | GestureType type{GestureType::Idle}; | ||
| 72 | GestureDirection direction{GestureDirection::None}; | ||
| 73 | Common::Point<s32> pos{}; | ||
| 74 | Common::Point<s32> delta{}; | ||
| 75 | f32 vel_x{}; | ||
| 76 | f32 vel_y{}; | ||
| 77 | GestureAttribute attributes{}; | ||
| 78 | f32 scale{}; | ||
| 79 | f32 rotation_angle{}; | ||
| 80 | s32 point_count{}; | ||
| 81 | std::array<Common::Point<s32>, 4> points{}; | ||
| 82 | }; | ||
| 83 | static_assert(sizeof(GestureState) == 0x60, "GestureState is an invalid size"); | ||
| 84 | |||
| 85 | struct GestureProperties { | ||
| 86 | std::array<Common::Point<s32>, MAX_POINTS> points{}; | ||
| 87 | std::size_t active_points{}; | ||
| 88 | Common::Point<s32> mid_point{}; | ||
| 89 | s64 detection_count{}; | ||
| 90 | u64 delta_time{}; | ||
| 91 | f32 average_distance{}; | ||
| 92 | f32 angle{}; | ||
| 93 | }; | ||
| 94 | |||
| 95 | struct GestureSharedMemory { | ||
| 96 | // This is nn::hid::detail::GestureLifo | ||
| 97 | Lifo<GestureState, hid_entry_count> gesture_lifo{}; | ||
| 98 | static_assert(sizeof(gesture_lifo) == 0x708, "gesture_lifo is an invalid size"); | ||
| 99 | INSERT_PADDING_WORDS(0x3E); | ||
| 100 | }; | ||
| 101 | static_assert(sizeof(GestureSharedMemory) == 0x800, "GestureSharedMemory is an invalid size"); | ||
| 102 | |||
| 103 | // Reads input from all available input engines | 35 | // Reads input from all available input engines |
| 104 | void ReadTouchInput(); | 36 | void ReadTouchInput(); |
| 105 | 37 | ||
| @@ -142,7 +74,7 @@ private: | |||
| 142 | GestureProperties GetGestureProperties(); | 74 | GestureProperties GetGestureProperties(); |
| 143 | 75 | ||
| 144 | GestureState next_state{}; | 76 | GestureState next_state{}; |
| 145 | GestureSharedMemory* shared_memory = nullptr; | 77 | GestureSharedMemoryFormat& shared_memory; |
| 146 | Core::HID::EmulatedConsole* console = nullptr; | 78 | Core::HID::EmulatedConsole* console = nullptr; |
| 147 | 79 | ||
| 148 | std::array<Core::HID::TouchFinger, MAX_POINTS> fingers{}; | 80 | std::array<Core::HID::TouchFinger, MAX_POINTS> fingers{}; |
diff --git a/src/core/hle/service/hid/controllers/keyboard.cpp b/src/core/hle/service/hid/controllers/keyboard.cpp index ddb1b0ba4..871e5036a 100644 --- a/src/core/hle/service/hid/controllers/keyboard.cpp +++ b/src/core/hle/service/hid/controllers/keyboard.cpp | |||
| @@ -1,23 +1,18 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include <cstring> | ||
| 5 | #include "common/common_types.h" | ||
| 6 | #include "common/settings.h" | 4 | #include "common/settings.h" |
| 7 | #include "core/core_timing.h" | 5 | #include "core/core_timing.h" |
| 8 | #include "core/hid/emulated_devices.h" | 6 | #include "core/hid/emulated_devices.h" |
| 9 | #include "core/hid/hid_core.h" | 7 | #include "core/hid/hid_core.h" |
| 10 | #include "core/hle/service/hid/controllers/keyboard.h" | 8 | #include "core/hle/service/hid/controllers/keyboard.h" |
| 9 | #include "core/hle/service/hid/controllers/shared_memory_format.h" | ||
| 11 | 10 | ||
| 12 | namespace Service::HID { | 11 | namespace Service::HID { |
| 13 | constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3800; | 12 | |
| 14 | 13 | Keyboard::Keyboard(Core::HID::HIDCore& hid_core_, | |
| 15 | Keyboard::Keyboard(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_) | 14 | KeyboardSharedMemoryFormat& keyboard_shared_memory) |
| 16 | : ControllerBase{hid_core_} { | 15 | : ControllerBase{hid_core_}, shared_memory{keyboard_shared_memory} { |
| 17 | static_assert(SHARED_MEMORY_OFFSET + sizeof(KeyboardSharedMemory) < shared_memory_size, | ||
| 18 | "KeyboardSharedMemory is bigger than the shared memory"); | ||
| 19 | shared_memory = std::construct_at( | ||
| 20 | reinterpret_cast<KeyboardSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET)); | ||
| 21 | emulated_devices = hid_core.GetEmulatedDevices(); | 16 | emulated_devices = hid_core.GetEmulatedDevices(); |
| 22 | } | 17 | } |
| 23 | 18 | ||
| @@ -29,12 +24,12 @@ void Keyboard::OnRelease() {} | |||
| 29 | 24 | ||
| 30 | void Keyboard::OnUpdate(const Core::Timing::CoreTiming& core_timing) { | 25 | void Keyboard::OnUpdate(const Core::Timing::CoreTiming& core_timing) { |
| 31 | if (!IsControllerActivated()) { | 26 | if (!IsControllerActivated()) { |
| 32 | shared_memory->keyboard_lifo.buffer_count = 0; | 27 | shared_memory.keyboard_lifo.buffer_count = 0; |
| 33 | shared_memory->keyboard_lifo.buffer_tail = 0; | 28 | shared_memory.keyboard_lifo.buffer_tail = 0; |
| 34 | return; | 29 | return; |
| 35 | } | 30 | } |
| 36 | 31 | ||
| 37 | const auto& last_entry = shared_memory->keyboard_lifo.ReadCurrentEntry().state; | 32 | const auto& last_entry = shared_memory.keyboard_lifo.ReadCurrentEntry().state; |
| 38 | next_state.sampling_number = last_entry.sampling_number + 1; | 33 | next_state.sampling_number = last_entry.sampling_number + 1; |
| 39 | 34 | ||
| 40 | if (Settings::values.keyboard_enabled) { | 35 | if (Settings::values.keyboard_enabled) { |
| @@ -46,7 +41,7 @@ void Keyboard::OnUpdate(const Core::Timing::CoreTiming& core_timing) { | |||
| 46 | next_state.attribute.is_connected.Assign(1); | 41 | next_state.attribute.is_connected.Assign(1); |
| 47 | } | 42 | } |
| 48 | 43 | ||
| 49 | shared_memory->keyboard_lifo.WriteNextEntry(next_state); | 44 | shared_memory.keyboard_lifo.WriteNextEntry(next_state); |
| 50 | } | 45 | } |
| 51 | 46 | ||
| 52 | } // namespace Service::HID | 47 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/controllers/keyboard.h b/src/core/hle/service/hid/controllers/keyboard.h index 172ec1309..4d72171b9 100644 --- a/src/core/hle/service/hid/controllers/keyboard.h +++ b/src/core/hle/service/hid/controllers/keyboard.h | |||
| @@ -3,20 +3,16 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "common/common_types.h" | ||
| 7 | #include "core/hle/service/hid/controllers/controller_base.h" | 6 | #include "core/hle/service/hid/controllers/controller_base.h" |
| 8 | #include "core/hle/service/hid/ring_lifo.h" | 7 | #include "core/hle/service/hid/controllers/types/keyboard_types.h" |
| 9 | |||
| 10 | namespace Core::HID { | ||
| 11 | class EmulatedDevices; | ||
| 12 | struct KeyboardModifier; | ||
| 13 | struct KeyboardKey; | ||
| 14 | } // namespace Core::HID | ||
| 15 | 8 | ||
| 16 | namespace Service::HID { | 9 | namespace Service::HID { |
| 10 | struct KeyboardSharedMemoryFormat; | ||
| 11 | |||
| 17 | class Keyboard final : public ControllerBase { | 12 | class Keyboard final : public ControllerBase { |
| 18 | public: | 13 | public: |
| 19 | explicit Keyboard(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_); | 14 | explicit Keyboard(Core::HID::HIDCore& hid_core_, |
| 15 | KeyboardSharedMemoryFormat& keyboard_shared_memory); | ||
| 20 | ~Keyboard() override; | 16 | ~Keyboard() override; |
| 21 | 17 | ||
| 22 | // Called when the controller is initialized | 18 | // Called when the controller is initialized |
| @@ -29,25 +25,8 @@ public: | |||
| 29 | void OnUpdate(const Core::Timing::CoreTiming& core_timing) override; | 25 | void OnUpdate(const Core::Timing::CoreTiming& core_timing) override; |
| 30 | 26 | ||
| 31 | private: | 27 | private: |
| 32 | // This is nn::hid::detail::KeyboardState | ||
| 33 | struct KeyboardState { | ||
| 34 | s64 sampling_number{}; | ||
| 35 | Core::HID::KeyboardModifier modifier{}; | ||
| 36 | Core::HID::KeyboardAttribute attribute{}; | ||
| 37 | Core::HID::KeyboardKey key{}; | ||
| 38 | }; | ||
| 39 | static_assert(sizeof(KeyboardState) == 0x30, "KeyboardState is an invalid size"); | ||
| 40 | |||
| 41 | struct KeyboardSharedMemory { | ||
| 42 | // This is nn::hid::detail::KeyboardLifo | ||
| 43 | Lifo<KeyboardState, hid_entry_count> keyboard_lifo{}; | ||
| 44 | static_assert(sizeof(keyboard_lifo) == 0x3D8, "keyboard_lifo is an invalid size"); | ||
| 45 | INSERT_PADDING_WORDS(0xA); | ||
| 46 | }; | ||
| 47 | static_assert(sizeof(KeyboardSharedMemory) == 0x400, "KeyboardSharedMemory is an invalid size"); | ||
| 48 | |||
| 49 | KeyboardState next_state{}; | 28 | KeyboardState next_state{}; |
| 50 | KeyboardSharedMemory* shared_memory = nullptr; | 29 | KeyboardSharedMemoryFormat& shared_memory; |
| 51 | Core::HID::EmulatedDevices* emulated_devices = nullptr; | 30 | Core::HID::EmulatedDevices* emulated_devices = nullptr; |
| 52 | }; | 31 | }; |
| 53 | } // namespace Service::HID | 32 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/controllers/mouse.cpp b/src/core/hle/service/hid/controllers/mouse.cpp index 6e5a04e34..de5b2c804 100644 --- a/src/core/hle/service/hid/controllers/mouse.cpp +++ b/src/core/hle/service/hid/controllers/mouse.cpp | |||
| @@ -1,22 +1,17 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include <cstring> | ||
| 5 | #include "common/common_types.h" | ||
| 6 | #include "core/core_timing.h" | 4 | #include "core/core_timing.h" |
| 7 | #include "core/frontend/emu_window.h" | 5 | #include "core/frontend/emu_window.h" |
| 8 | #include "core/hid/emulated_devices.h" | 6 | #include "core/hid/emulated_devices.h" |
| 9 | #include "core/hid/hid_core.h" | 7 | #include "core/hid/hid_core.h" |
| 10 | #include "core/hle/service/hid/controllers/mouse.h" | 8 | #include "core/hle/service/hid/controllers/mouse.h" |
| 9 | #include "core/hle/service/hid/controllers/shared_memory_format.h" | ||
| 11 | 10 | ||
| 12 | namespace Service::HID { | 11 | namespace Service::HID { |
| 13 | constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3400; | ||
| 14 | 12 | ||
| 15 | Mouse::Mouse(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_) : ControllerBase{hid_core_} { | 13 | Mouse::Mouse(Core::HID::HIDCore& hid_core_, MouseSharedMemoryFormat& mouse_shared_memory) |
| 16 | static_assert(SHARED_MEMORY_OFFSET + sizeof(MouseSharedMemory) < shared_memory_size, | 14 | : ControllerBase{hid_core_}, shared_memory{mouse_shared_memory} { |
| 17 | "MouseSharedMemory is bigger than the shared memory"); | ||
| 18 | shared_memory = std::construct_at( | ||
| 19 | reinterpret_cast<MouseSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET)); | ||
| 20 | emulated_devices = hid_core.GetEmulatedDevices(); | 15 | emulated_devices = hid_core.GetEmulatedDevices(); |
| 21 | } | 16 | } |
| 22 | 17 | ||
| @@ -27,14 +22,14 @@ void Mouse::OnRelease() {} | |||
| 27 | 22 | ||
| 28 | void Mouse::OnUpdate(const Core::Timing::CoreTiming& core_timing) { | 23 | void Mouse::OnUpdate(const Core::Timing::CoreTiming& core_timing) { |
| 29 | if (!IsControllerActivated()) { | 24 | if (!IsControllerActivated()) { |
| 30 | shared_memory->mouse_lifo.buffer_count = 0; | 25 | shared_memory.mouse_lifo.buffer_count = 0; |
| 31 | shared_memory->mouse_lifo.buffer_tail = 0; | 26 | shared_memory.mouse_lifo.buffer_tail = 0; |
| 32 | return; | 27 | return; |
| 33 | } | 28 | } |
| 34 | 29 | ||
| 35 | next_state = {}; | 30 | next_state = {}; |
| 36 | 31 | ||
| 37 | const auto& last_entry = shared_memory->mouse_lifo.ReadCurrentEntry().state; | 32 | const auto& last_entry = shared_memory.mouse_lifo.ReadCurrentEntry().state; |
| 38 | next_state.sampling_number = last_entry.sampling_number + 1; | 33 | next_state.sampling_number = last_entry.sampling_number + 1; |
| 39 | 34 | ||
| 40 | if (Settings::values.mouse_enabled) { | 35 | if (Settings::values.mouse_enabled) { |
| @@ -53,7 +48,7 @@ void Mouse::OnUpdate(const Core::Timing::CoreTiming& core_timing) { | |||
| 53 | next_state.button = mouse_button_state; | 48 | next_state.button = mouse_button_state; |
| 54 | } | 49 | } |
| 55 | 50 | ||
| 56 | shared_memory->mouse_lifo.WriteNextEntry(next_state); | 51 | shared_memory.mouse_lifo.WriteNextEntry(next_state); |
| 57 | } | 52 | } |
| 58 | 53 | ||
| 59 | } // namespace Service::HID | 54 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/controllers/mouse.h b/src/core/hle/service/hid/controllers/mouse.h index a80f3823f..363f316a5 100644 --- a/src/core/hle/service/hid/controllers/mouse.h +++ b/src/core/hle/service/hid/controllers/mouse.h | |||
| @@ -3,9 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "common/common_types.h" | ||
| 7 | #include "core/hle/service/hid/controllers/controller_base.h" | 6 | #include "core/hle/service/hid/controllers/controller_base.h" |
| 8 | #include "core/hle/service/hid/ring_lifo.h" | ||
| 9 | 7 | ||
| 10 | namespace Core::HID { | 8 | namespace Core::HID { |
| 11 | class EmulatedDevices; | 9 | class EmulatedDevices; |
| @@ -14,9 +12,11 @@ struct AnalogStickState; | |||
| 14 | } // namespace Core::HID | 12 | } // namespace Core::HID |
| 15 | 13 | ||
| 16 | namespace Service::HID { | 14 | namespace Service::HID { |
| 15 | struct MouseSharedMemoryFormat; | ||
| 16 | |||
| 17 | class Mouse final : public ControllerBase { | 17 | class Mouse final : public ControllerBase { |
| 18 | public: | 18 | public: |
| 19 | explicit Mouse(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_); | 19 | explicit Mouse(Core::HID::HIDCore& hid_core_, MouseSharedMemoryFormat& mouse_shared_memory); |
| 20 | ~Mouse() override; | 20 | ~Mouse() override; |
| 21 | 21 | ||
| 22 | // Called when the controller is initialized | 22 | // Called when the controller is initialized |
| @@ -29,17 +29,9 @@ public: | |||
| 29 | void OnUpdate(const Core::Timing::CoreTiming& core_timing) override; | 29 | void OnUpdate(const Core::Timing::CoreTiming& core_timing) override; |
| 30 | 30 | ||
| 31 | private: | 31 | private: |
| 32 | struct MouseSharedMemory { | ||
| 33 | // This is nn::hid::detail::MouseLifo | ||
| 34 | Lifo<Core::HID::MouseState, hid_entry_count> mouse_lifo{}; | ||
| 35 | static_assert(sizeof(mouse_lifo) == 0x350, "mouse_lifo is an invalid size"); | ||
| 36 | INSERT_PADDING_WORDS(0x2C); | ||
| 37 | }; | ||
| 38 | static_assert(sizeof(MouseSharedMemory) == 0x400, "MouseSharedMemory is an invalid size"); | ||
| 39 | |||
| 40 | Core::HID::MouseState next_state{}; | 32 | Core::HID::MouseState next_state{}; |
| 41 | Core::HID::AnalogStickState last_mouse_wheel_state{}; | 33 | Core::HID::AnalogStickState last_mouse_wheel_state{}; |
| 42 | MouseSharedMemory* shared_memory = nullptr; | 34 | MouseSharedMemoryFormat& shared_memory; |
| 43 | Core::HID::EmulatedDevices* emulated_devices = nullptr; | 35 | Core::HID::EmulatedDevices* emulated_devices = nullptr; |
| 44 | }; | 36 | }; |
| 45 | } // namespace Service::HID | 37 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 08ee9de9c..53a737cf5 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp | |||
| @@ -17,12 +17,12 @@ | |||
| 17 | #include "core/hle/kernel/k_event.h" | 17 | #include "core/hle/kernel/k_event.h" |
| 18 | #include "core/hle/kernel/k_readable_event.h" | 18 | #include "core/hle/kernel/k_readable_event.h" |
| 19 | #include "core/hle/service/hid/controllers/npad.h" | 19 | #include "core/hle/service/hid/controllers/npad.h" |
| 20 | #include "core/hle/service/hid/controllers/shared_memory_format.h" | ||
| 20 | #include "core/hle/service/hid/errors.h" | 21 | #include "core/hle/service/hid/errors.h" |
| 21 | #include "core/hle/service/hid/hid_util.h" | 22 | #include "core/hle/service/hid/hid_util.h" |
| 22 | #include "core/hle/service/kernel_helpers.h" | 23 | #include "core/hle/service/kernel_helpers.h" |
| 23 | 24 | ||
| 24 | namespace Service::HID { | 25 | namespace Service::HID { |
| 25 | constexpr std::size_t NPAD_OFFSET = 0x9A00; | ||
| 26 | constexpr std::array<Core::HID::NpadIdType, 10> npad_id_list{ | 26 | constexpr std::array<Core::HID::NpadIdType, 10> npad_id_list{ |
| 27 | Core::HID::NpadIdType::Player1, Core::HID::NpadIdType::Player2, Core::HID::NpadIdType::Player3, | 27 | Core::HID::NpadIdType::Player1, Core::HID::NpadIdType::Player2, Core::HID::NpadIdType::Player3, |
| 28 | Core::HID::NpadIdType::Player4, Core::HID::NpadIdType::Player5, Core::HID::NpadIdType::Player6, | 28 | Core::HID::NpadIdType::Player4, Core::HID::NpadIdType::Player5, Core::HID::NpadIdType::Player6, |
| @@ -30,14 +30,12 @@ constexpr std::array<Core::HID::NpadIdType, 10> npad_id_list{ | |||
| 30 | Core::HID::NpadIdType::Handheld, | 30 | Core::HID::NpadIdType::Handheld, |
| 31 | }; | 31 | }; |
| 32 | 32 | ||
| 33 | NPad::NPad(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_, | 33 | NPad::NPad(Core::HID::HIDCore& hid_core_, NpadSharedMemoryFormat& npad_shared_memory_format, |
| 34 | KernelHelpers::ServiceContext& service_context_) | 34 | KernelHelpers::ServiceContext& service_context_) |
| 35 | : ControllerBase{hid_core_}, service_context{service_context_} { | 35 | : ControllerBase{hid_core_}, service_context{service_context_} { |
| 36 | static_assert(NPAD_OFFSET + (NPAD_COUNT * sizeof(NpadInternalState)) < shared_memory_size); | ||
| 37 | for (std::size_t i = 0; i < controller_data.size(); ++i) { | 36 | for (std::size_t i = 0; i < controller_data.size(); ++i) { |
| 38 | auto& controller = controller_data[i]; | 37 | auto& controller = controller_data[i]; |
| 39 | controller.shared_memory = std::construct_at(reinterpret_cast<NpadInternalState*>( | 38 | controller.shared_memory = &npad_shared_memory_format.npad_entry[i].internal_state; |
| 40 | raw_shared_memory_ + NPAD_OFFSET + (i * sizeof(NpadInternalState)))); | ||
| 41 | controller.device = hid_core.GetEmulatedControllerByIndex(i); | 39 | controller.device = hid_core.GetEmulatedControllerByIndex(i); |
| 42 | controller.vibration[Core::HID::EmulatedDeviceIndex::LeftIndex].latest_vibration_value = | 40 | controller.vibration[Core::HID::EmulatedDeviceIndex::LeftIndex].latest_vibration_value = |
| 43 | Core::HID::DEFAULT_VIBRATION_VALUE; | 41 | Core::HID::DEFAULT_VIBRATION_VALUE; |
| @@ -617,7 +615,7 @@ void NPad::SetHoldType(NpadJoyHoldType joy_hold_type) { | |||
| 617 | hold_type = joy_hold_type; | 615 | hold_type = joy_hold_type; |
| 618 | } | 616 | } |
| 619 | 617 | ||
| 620 | NPad::NpadJoyHoldType NPad::GetHoldType() const { | 618 | NpadJoyHoldType NPad::GetHoldType() const { |
| 621 | return hold_type; | 619 | return hold_type; |
| 622 | } | 620 | } |
| 623 | 621 | ||
| @@ -630,7 +628,7 @@ void NPad::SetNpadHandheldActivationMode(NpadHandheldActivationMode activation_m | |||
| 630 | handheld_activation_mode = activation_mode; | 628 | handheld_activation_mode = activation_mode; |
| 631 | } | 629 | } |
| 632 | 630 | ||
| 633 | NPad::NpadHandheldActivationMode NPad::GetNpadHandheldActivationMode() const { | 631 | NpadHandheldActivationMode NPad::GetNpadHandheldActivationMode() const { |
| 634 | return handheld_activation_mode; | 632 | return handheld_activation_mode; |
| 635 | } | 633 | } |
| 636 | 634 | ||
| @@ -638,7 +636,7 @@ void NPad::SetNpadCommunicationMode(NpadCommunicationMode communication_mode_) { | |||
| 638 | communication_mode = communication_mode_; | 636 | communication_mode = communication_mode_; |
| 639 | } | 637 | } |
| 640 | 638 | ||
| 641 | NPad::NpadCommunicationMode NPad::GetNpadCommunicationMode() const { | 639 | NpadCommunicationMode NPad::GetNpadCommunicationMode() const { |
| 642 | return communication_mode; | 640 | return communication_mode; |
| 643 | } | 641 | } |
| 644 | 642 | ||
| @@ -978,27 +976,27 @@ Result NPad::ResetIsSixAxisSensorDeviceNewlyAssigned( | |||
| 978 | return ResultSuccess; | 976 | return ResultSuccess; |
| 979 | } | 977 | } |
| 980 | 978 | ||
| 981 | NPad::SixAxisLifo& NPad::GetSixAxisFullkeyLifo(Core::HID::NpadIdType npad_id) { | 979 | NpadSixAxisSensorLifo& NPad::GetSixAxisFullkeyLifo(Core::HID::NpadIdType npad_id) { |
| 982 | return GetControllerFromNpadIdType(npad_id).shared_memory->sixaxis_fullkey_lifo; | 980 | return GetControllerFromNpadIdType(npad_id).shared_memory->sixaxis_fullkey_lifo; |
| 983 | } | 981 | } |
| 984 | 982 | ||
| 985 | NPad::SixAxisLifo& NPad::GetSixAxisHandheldLifo(Core::HID::NpadIdType npad_id) { | 983 | NpadSixAxisSensorLifo& NPad::GetSixAxisHandheldLifo(Core::HID::NpadIdType npad_id) { |
| 986 | return GetControllerFromNpadIdType(npad_id).shared_memory->sixaxis_handheld_lifo; | 984 | return GetControllerFromNpadIdType(npad_id).shared_memory->sixaxis_handheld_lifo; |
| 987 | } | 985 | } |
| 988 | 986 | ||
| 989 | NPad::SixAxisLifo& NPad::GetSixAxisDualLeftLifo(Core::HID::NpadIdType npad_id) { | 987 | NpadSixAxisSensorLifo& NPad::GetSixAxisDualLeftLifo(Core::HID::NpadIdType npad_id) { |
| 990 | return GetControllerFromNpadIdType(npad_id).shared_memory->sixaxis_dual_left_lifo; | 988 | return GetControllerFromNpadIdType(npad_id).shared_memory->sixaxis_dual_left_lifo; |
| 991 | } | 989 | } |
| 992 | 990 | ||
| 993 | NPad::SixAxisLifo& NPad::GetSixAxisDualRightLifo(Core::HID::NpadIdType npad_id) { | 991 | NpadSixAxisSensorLifo& NPad::GetSixAxisDualRightLifo(Core::HID::NpadIdType npad_id) { |
| 994 | return GetControllerFromNpadIdType(npad_id).shared_memory->sixaxis_dual_right_lifo; | 992 | return GetControllerFromNpadIdType(npad_id).shared_memory->sixaxis_dual_right_lifo; |
| 995 | } | 993 | } |
| 996 | 994 | ||
| 997 | NPad::SixAxisLifo& NPad::GetSixAxisLeftLifo(Core::HID::NpadIdType npad_id) { | 995 | NpadSixAxisSensorLifo& NPad::GetSixAxisLeftLifo(Core::HID::NpadIdType npad_id) { |
| 998 | return GetControllerFromNpadIdType(npad_id).shared_memory->sixaxis_left_lifo; | 996 | return GetControllerFromNpadIdType(npad_id).shared_memory->sixaxis_left_lifo; |
| 999 | } | 997 | } |
| 1000 | 998 | ||
| 1001 | NPad::SixAxisLifo& NPad::GetSixAxisRightLifo(Core::HID::NpadIdType npad_id) { | 999 | NpadSixAxisSensorLifo& NPad::GetSixAxisRightLifo(Core::HID::NpadIdType npad_id) { |
| 1002 | return GetControllerFromNpadIdType(npad_id).shared_memory->sixaxis_right_lifo; | 1000 | return GetControllerFromNpadIdType(npad_id).shared_memory->sixaxis_right_lifo; |
| 1003 | } | 1001 | } |
| 1004 | 1002 | ||
| @@ -1343,7 +1341,7 @@ const Core::HID::SixAxisSensorProperties& NPad::GetSixaxisProperties( | |||
| 1343 | } | 1341 | } |
| 1344 | } | 1342 | } |
| 1345 | 1343 | ||
| 1346 | NPad::AppletDetailedUiType NPad::GetAppletDetailedUiType(Core::HID::NpadIdType npad_id) { | 1344 | AppletDetailedUiType NPad::GetAppletDetailedUiType(Core::HID::NpadIdType npad_id) { |
| 1347 | const auto& shared_memory = GetControllerFromNpadIdType(npad_id).shared_memory; | 1345 | const auto& shared_memory = GetControllerFromNpadIdType(npad_id).shared_memory; |
| 1348 | 1346 | ||
| 1349 | return { | 1347 | return { |
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 9167c93f0..4e2412356 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h | |||
| @@ -8,12 +8,10 @@ | |||
| 8 | #include <mutex> | 8 | #include <mutex> |
| 9 | #include <span> | 9 | #include <span> |
| 10 | 10 | ||
| 11 | #include "common/bit_field.h" | ||
| 12 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 13 | |||
| 14 | #include "core/hid/hid_types.h" | 12 | #include "core/hid/hid_types.h" |
| 15 | #include "core/hle/service/hid/controllers/controller_base.h" | 13 | #include "core/hle/service/hid/controllers/controller_base.h" |
| 16 | #include "core/hle/service/hid/ring_lifo.h" | 14 | #include "core/hle/service/hid/controllers/types/npad_types.h" |
| 17 | 15 | ||
| 18 | namespace Core::HID { | 16 | namespace Core::HID { |
| 19 | class EmulatedController; | 17 | class EmulatedController; |
| @@ -32,10 +30,13 @@ class ServiceContext; | |||
| 32 | union Result; | 30 | union Result; |
| 33 | 31 | ||
| 34 | namespace Service::HID { | 32 | namespace Service::HID { |
| 33 | struct NpadInternalState; | ||
| 34 | struct NpadSixAxisSensorLifo; | ||
| 35 | struct NpadSharedMemoryFormat; | ||
| 35 | 36 | ||
| 36 | class NPad final : public ControllerBase { | 37 | class NPad final : public ControllerBase { |
| 37 | public: | 38 | public: |
| 38 | explicit NPad(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_, | 39 | explicit NPad(Core::HID::HIDCore& hid_core_, NpadSharedMemoryFormat& npad_shared_memory_format, |
| 39 | KernelHelpers::ServiceContext& service_context_); | 40 | KernelHelpers::ServiceContext& service_context_); |
| 40 | ~NPad() override; | 41 | ~NPad() override; |
| 41 | 42 | ||
| @@ -48,89 +49,6 @@ public: | |||
| 48 | // When the controller is requesting an update for the shared memory | 49 | // When the controller is requesting an update for the shared memory |
| 49 | void OnUpdate(const Core::Timing::CoreTiming& core_timing) override; | 50 | void OnUpdate(const Core::Timing::CoreTiming& core_timing) override; |
| 50 | 51 | ||
| 51 | // This is nn::hid::NpadJoyHoldType | ||
| 52 | enum class NpadJoyHoldType : u64 { | ||
| 53 | Vertical = 0, | ||
| 54 | Horizontal = 1, | ||
| 55 | }; | ||
| 56 | |||
| 57 | // This is nn::hid::NpadJoyAssignmentMode | ||
| 58 | enum class NpadJoyAssignmentMode : u32 { | ||
| 59 | Dual = 0, | ||
| 60 | Single = 1, | ||
| 61 | }; | ||
| 62 | |||
| 63 | // This is nn::hid::NpadJoyDeviceType | ||
| 64 | enum class NpadJoyDeviceType : s64 { | ||
| 65 | Left = 0, | ||
| 66 | Right = 1, | ||
| 67 | }; | ||
| 68 | |||
| 69 | // This is nn::hid::NpadHandheldActivationMode | ||
| 70 | enum class NpadHandheldActivationMode : u64 { | ||
| 71 | Dual = 0, | ||
| 72 | Single = 1, | ||
| 73 | None = 2, | ||
| 74 | MaxActivationMode = 3, | ||
| 75 | }; | ||
| 76 | |||
| 77 | // This is nn::hid::system::AppletFooterUiAttributesSet | ||
| 78 | struct AppletFooterUiAttributes { | ||
| 79 | INSERT_PADDING_BYTES(0x4); | ||
| 80 | }; | ||
| 81 | |||
| 82 | // This is nn::hid::system::AppletFooterUiType | ||
| 83 | enum class AppletFooterUiType : u8 { | ||
| 84 | None = 0, | ||
| 85 | HandheldNone = 1, | ||
| 86 | HandheldJoyConLeftOnly = 2, | ||
| 87 | HandheldJoyConRightOnly = 3, | ||
| 88 | HandheldJoyConLeftJoyConRight = 4, | ||
| 89 | JoyDual = 5, | ||
| 90 | JoyDualLeftOnly = 6, | ||
| 91 | JoyDualRightOnly = 7, | ||
| 92 | JoyLeftHorizontal = 8, | ||
| 93 | JoyLeftVertical = 9, | ||
| 94 | JoyRightHorizontal = 10, | ||
| 95 | JoyRightVertical = 11, | ||
| 96 | SwitchProController = 12, | ||
| 97 | CompatibleProController = 13, | ||
| 98 | CompatibleJoyCon = 14, | ||
| 99 | LarkHvc1 = 15, | ||
| 100 | LarkHvc2 = 16, | ||
| 101 | LarkNesLeft = 17, | ||
| 102 | LarkNesRight = 18, | ||
| 103 | Lucia = 19, | ||
| 104 | Verification = 20, | ||
| 105 | Lagon = 21, | ||
| 106 | }; | ||
| 107 | |||
| 108 | using AppletFooterUiVariant = u8; | ||
| 109 | |||
| 110 | // This is "nn::hid::system::AppletDetailedUiType". | ||
| 111 | struct AppletDetailedUiType { | ||
| 112 | AppletFooterUiVariant ui_variant; | ||
| 113 | INSERT_PADDING_BYTES(0x2); | ||
| 114 | AppletFooterUiType footer; | ||
| 115 | }; | ||
| 116 | static_assert(sizeof(AppletDetailedUiType) == 0x4, "AppletDetailedUiType is an invalid size"); | ||
| 117 | // This is nn::hid::NpadCommunicationMode | ||
| 118 | enum class NpadCommunicationMode : u64 { | ||
| 119 | Mode_5ms = 0, | ||
| 120 | Mode_10ms = 1, | ||
| 121 | Mode_15ms = 2, | ||
| 122 | Default = 3, | ||
| 123 | }; | ||
| 124 | |||
| 125 | enum class NpadRevision : u32 { | ||
| 126 | Revision0 = 0, | ||
| 127 | Revision1 = 1, | ||
| 128 | Revision2 = 2, | ||
| 129 | Revision3 = 3, | ||
| 130 | }; | ||
| 131 | |||
| 132 | using SixAxisLifo = Lifo<Core::HID::SixAxisSensorState, hid_entry_count>; | ||
| 133 | |||
| 134 | void SetSupportedStyleSet(Core::HID::NpadStyleTag style_set); | 52 | void SetSupportedStyleSet(Core::HID::NpadStyleTag style_set); |
| 135 | Core::HID::NpadStyleTag GetSupportedStyleSet() const; | 53 | Core::HID::NpadStyleTag GetSupportedStyleSet() const; |
| 136 | 54 | ||
| @@ -188,12 +106,12 @@ public: | |||
| 188 | Result ResetIsSixAxisSensorDeviceNewlyAssigned( | 106 | Result ResetIsSixAxisSensorDeviceNewlyAssigned( |
| 189 | const Core::HID::SixAxisSensorHandle& sixaxis_handle); | 107 | const Core::HID::SixAxisSensorHandle& sixaxis_handle); |
| 190 | 108 | ||
| 191 | SixAxisLifo& GetSixAxisFullkeyLifo(Core::HID::NpadIdType npad_id); | 109 | NpadSixAxisSensorLifo& GetSixAxisFullkeyLifo(Core::HID::NpadIdType npad_id); |
| 192 | SixAxisLifo& GetSixAxisHandheldLifo(Core::HID::NpadIdType npad_id); | 110 | NpadSixAxisSensorLifo& GetSixAxisHandheldLifo(Core::HID::NpadIdType npad_id); |
| 193 | SixAxisLifo& GetSixAxisDualLeftLifo(Core::HID::NpadIdType npad_id); | 111 | NpadSixAxisSensorLifo& GetSixAxisDualLeftLifo(Core::HID::NpadIdType npad_id); |
| 194 | SixAxisLifo& GetSixAxisDualRightLifo(Core::HID::NpadIdType npad_id); | 112 | NpadSixAxisSensorLifo& GetSixAxisDualRightLifo(Core::HID::NpadIdType npad_id); |
| 195 | SixAxisLifo& GetSixAxisLeftLifo(Core::HID::NpadIdType npad_id); | 113 | NpadSixAxisSensorLifo& GetSixAxisLeftLifo(Core::HID::NpadIdType npad_id); |
| 196 | SixAxisLifo& GetSixAxisRightLifo(Core::HID::NpadIdType npad_id); | 114 | NpadSixAxisSensorLifo& GetSixAxisRightLifo(Core::HID::NpadIdType npad_id); |
| 197 | 115 | ||
| 198 | Result GetLedPattern(Core::HID::NpadIdType npad_id, Core::HID::LedPattern& pattern) const; | 116 | Result GetLedPattern(Core::HID::NpadIdType npad_id, Core::HID::LedPattern& pattern) const; |
| 199 | Result IsUnintendedHomeButtonInputProtectionEnabled(Core::HID::NpadIdType npad_id, | 117 | Result IsUnintendedHomeButtonInputProtectionEnabled(Core::HID::NpadIdType npad_id, |
| @@ -221,214 +139,6 @@ public: | |||
| 221 | AppletDetailedUiType GetAppletDetailedUiType(Core::HID::NpadIdType npad_id); | 139 | AppletDetailedUiType GetAppletDetailedUiType(Core::HID::NpadIdType npad_id); |
| 222 | 140 | ||
| 223 | private: | 141 | private: |
| 224 | static constexpr std::size_t NPAD_COUNT = 10; | ||
| 225 | |||
| 226 | // This is nn::hid::detail::ColorAttribute | ||
| 227 | enum class ColorAttribute : u32 { | ||
| 228 | Ok = 0, | ||
| 229 | ReadError = 1, | ||
| 230 | NoController = 2, | ||
| 231 | }; | ||
| 232 | static_assert(sizeof(ColorAttribute) == 4, "ColorAttribute is an invalid size"); | ||
| 233 | |||
| 234 | // This is nn::hid::detail::NpadFullKeyColorState | ||
| 235 | struct NpadFullKeyColorState { | ||
| 236 | ColorAttribute attribute{ColorAttribute::NoController}; | ||
| 237 | Core::HID::NpadControllerColor fullkey{}; | ||
| 238 | }; | ||
| 239 | static_assert(sizeof(NpadFullKeyColorState) == 0xC, "NpadFullKeyColorState is an invalid size"); | ||
| 240 | |||
| 241 | // This is nn::hid::detail::NpadJoyColorState | ||
| 242 | struct NpadJoyColorState { | ||
| 243 | ColorAttribute attribute{ColorAttribute::NoController}; | ||
| 244 | Core::HID::NpadControllerColor left{}; | ||
| 245 | Core::HID::NpadControllerColor right{}; | ||
| 246 | }; | ||
| 247 | static_assert(sizeof(NpadJoyColorState) == 0x14, "NpadJoyColorState is an invalid size"); | ||
| 248 | |||
| 249 | // This is nn::hid::NpadAttribute | ||
| 250 | struct NpadAttribute { | ||
| 251 | union { | ||
| 252 | u32 raw{}; | ||
| 253 | BitField<0, 1, u32> is_connected; | ||
| 254 | BitField<1, 1, u32> is_wired; | ||
| 255 | BitField<2, 1, u32> is_left_connected; | ||
| 256 | BitField<3, 1, u32> is_left_wired; | ||
| 257 | BitField<4, 1, u32> is_right_connected; | ||
| 258 | BitField<5, 1, u32> is_right_wired; | ||
| 259 | }; | ||
| 260 | }; | ||
| 261 | static_assert(sizeof(NpadAttribute) == 4, "NpadAttribute is an invalid size"); | ||
| 262 | |||
| 263 | // This is nn::hid::NpadFullKeyState | ||
| 264 | // This is nn::hid::NpadHandheldState | ||
| 265 | // This is nn::hid::NpadJoyDualState | ||
| 266 | // This is nn::hid::NpadJoyLeftState | ||
| 267 | // This is nn::hid::NpadJoyRightState | ||
| 268 | // This is nn::hid::NpadPalmaState | ||
| 269 | // This is nn::hid::NpadSystemExtState | ||
| 270 | struct NPadGenericState { | ||
| 271 | s64_le sampling_number{}; | ||
| 272 | Core::HID::NpadButtonState npad_buttons{}; | ||
| 273 | Core::HID::AnalogStickState l_stick{}; | ||
| 274 | Core::HID::AnalogStickState r_stick{}; | ||
| 275 | NpadAttribute connection_status{}; | ||
| 276 | INSERT_PADDING_BYTES(4); // Reserved | ||
| 277 | }; | ||
| 278 | static_assert(sizeof(NPadGenericState) == 0x28, "NPadGenericState is an invalid size"); | ||
| 279 | |||
| 280 | // This is nn::hid::server::NpadGcTriggerState | ||
| 281 | struct NpadGcTriggerState { | ||
| 282 | s64 sampling_number{}; | ||
| 283 | s32 l_analog{}; | ||
| 284 | s32 r_analog{}; | ||
| 285 | }; | ||
| 286 | static_assert(sizeof(NpadGcTriggerState) == 0x10, "NpadGcTriggerState is an invalid size"); | ||
| 287 | |||
| 288 | // This is nn::hid::NpadSystemProperties | ||
| 289 | struct NPadSystemProperties { | ||
| 290 | union { | ||
| 291 | s64 raw{}; | ||
| 292 | BitField<0, 1, s64> is_charging_joy_dual; | ||
| 293 | BitField<1, 1, s64> is_charging_joy_left; | ||
| 294 | BitField<2, 1, s64> is_charging_joy_right; | ||
| 295 | BitField<3, 1, s64> is_powered_joy_dual; | ||
| 296 | BitField<4, 1, s64> is_powered_joy_left; | ||
| 297 | BitField<5, 1, s64> is_powered_joy_right; | ||
| 298 | BitField<9, 1, s64> is_system_unsupported_button; | ||
| 299 | BitField<10, 1, s64> is_system_ext_unsupported_button; | ||
| 300 | BitField<11, 1, s64> is_vertical; | ||
| 301 | BitField<12, 1, s64> is_horizontal; | ||
| 302 | BitField<13, 1, s64> use_plus; | ||
| 303 | BitField<14, 1, s64> use_minus; | ||
| 304 | BitField<15, 1, s64> use_directional_buttons; | ||
| 305 | }; | ||
| 306 | }; | ||
| 307 | static_assert(sizeof(NPadSystemProperties) == 0x8, "NPadSystemProperties is an invalid size"); | ||
| 308 | |||
| 309 | // This is nn::hid::NpadSystemButtonProperties | ||
| 310 | struct NpadSystemButtonProperties { | ||
| 311 | union { | ||
| 312 | s32 raw{}; | ||
| 313 | BitField<0, 1, s32> is_home_button_protection_enabled; | ||
| 314 | }; | ||
| 315 | }; | ||
| 316 | static_assert(sizeof(NpadSystemButtonProperties) == 0x4, | ||
| 317 | "NPadButtonProperties is an invalid size"); | ||
| 318 | |||
| 319 | // This is nn::hid::system::DeviceType | ||
| 320 | struct DeviceType { | ||
| 321 | union { | ||
| 322 | u32 raw{}; | ||
| 323 | BitField<0, 1, s32> fullkey; | ||
| 324 | BitField<1, 1, s32> debug_pad; | ||
| 325 | BitField<2, 1, s32> handheld_left; | ||
| 326 | BitField<3, 1, s32> handheld_right; | ||
| 327 | BitField<4, 1, s32> joycon_left; | ||
| 328 | BitField<5, 1, s32> joycon_right; | ||
| 329 | BitField<6, 1, s32> palma; | ||
| 330 | BitField<7, 1, s32> lark_hvc_left; | ||
| 331 | BitField<8, 1, s32> lark_hvc_right; | ||
| 332 | BitField<9, 1, s32> lark_nes_left; | ||
| 333 | BitField<10, 1, s32> lark_nes_right; | ||
| 334 | BitField<11, 1, s32> handheld_lark_hvc_left; | ||
| 335 | BitField<12, 1, s32> handheld_lark_hvc_right; | ||
| 336 | BitField<13, 1, s32> handheld_lark_nes_left; | ||
| 337 | BitField<14, 1, s32> handheld_lark_nes_right; | ||
| 338 | BitField<15, 1, s32> lucia; | ||
| 339 | BitField<16, 1, s32> lagon; | ||
| 340 | BitField<17, 1, s32> lager; | ||
| 341 | BitField<31, 1, s32> system; | ||
| 342 | }; | ||
| 343 | }; | ||
| 344 | |||
| 345 | // This is nn::hid::detail::NfcXcdDeviceHandleStateImpl | ||
| 346 | struct NfcXcdDeviceHandleStateImpl { | ||
| 347 | u64 handle{}; | ||
| 348 | bool is_available{}; | ||
| 349 | bool is_activated{}; | ||
| 350 | INSERT_PADDING_BYTES(0x6); // Reserved | ||
| 351 | u64 sampling_number{}; | ||
| 352 | }; | ||
| 353 | static_assert(sizeof(NfcXcdDeviceHandleStateImpl) == 0x18, | ||
| 354 | "NfcXcdDeviceHandleStateImpl is an invalid size"); | ||
| 355 | |||
| 356 | // This is nn::hid::NpadLarkType | ||
| 357 | enum class NpadLarkType : u32 { | ||
| 358 | Invalid, | ||
| 359 | H1, | ||
| 360 | H2, | ||
| 361 | NL, | ||
| 362 | NR, | ||
| 363 | }; | ||
| 364 | |||
| 365 | // This is nn::hid::NpadLuciaType | ||
| 366 | enum class NpadLuciaType : u32 { | ||
| 367 | Invalid, | ||
| 368 | J, | ||
| 369 | E, | ||
| 370 | U, | ||
| 371 | }; | ||
| 372 | |||
| 373 | // This is nn::hid::NpadLagonType | ||
| 374 | enum class NpadLagonType : u32 { | ||
| 375 | Invalid, | ||
| 376 | }; | ||
| 377 | |||
| 378 | // This is nn::hid::NpadLagerType | ||
| 379 | enum class NpadLagerType : u32 { | ||
| 380 | Invalid, | ||
| 381 | J, | ||
| 382 | E, | ||
| 383 | U, | ||
| 384 | }; | ||
| 385 | |||
| 386 | // This is nn::hid::detail::NpadInternalState | ||
| 387 | struct NpadInternalState { | ||
| 388 | Core::HID::NpadStyleTag style_tag{Core::HID::NpadStyleSet::None}; | ||
| 389 | NpadJoyAssignmentMode assignment_mode{NpadJoyAssignmentMode::Dual}; | ||
| 390 | NpadFullKeyColorState fullkey_color{}; | ||
| 391 | NpadJoyColorState joycon_color{}; | ||
| 392 | Lifo<NPadGenericState, hid_entry_count> fullkey_lifo{}; | ||
| 393 | Lifo<NPadGenericState, hid_entry_count> handheld_lifo{}; | ||
| 394 | Lifo<NPadGenericState, hid_entry_count> joy_dual_lifo{}; | ||
| 395 | Lifo<NPadGenericState, hid_entry_count> joy_left_lifo{}; | ||
| 396 | Lifo<NPadGenericState, hid_entry_count> joy_right_lifo{}; | ||
| 397 | Lifo<NPadGenericState, hid_entry_count> palma_lifo{}; | ||
| 398 | Lifo<NPadGenericState, hid_entry_count> system_ext_lifo{}; | ||
| 399 | Lifo<Core::HID::SixAxisSensorState, hid_entry_count> sixaxis_fullkey_lifo{}; | ||
| 400 | Lifo<Core::HID::SixAxisSensorState, hid_entry_count> sixaxis_handheld_lifo{}; | ||
| 401 | Lifo<Core::HID::SixAxisSensorState, hid_entry_count> sixaxis_dual_left_lifo{}; | ||
| 402 | Lifo<Core::HID::SixAxisSensorState, hid_entry_count> sixaxis_dual_right_lifo{}; | ||
| 403 | Lifo<Core::HID::SixAxisSensorState, hid_entry_count> sixaxis_left_lifo{}; | ||
| 404 | Lifo<Core::HID::SixAxisSensorState, hid_entry_count> sixaxis_right_lifo{}; | ||
| 405 | DeviceType device_type{}; | ||
| 406 | INSERT_PADDING_BYTES(0x4); // Reserved | ||
| 407 | NPadSystemProperties system_properties{}; | ||
| 408 | NpadSystemButtonProperties button_properties{}; | ||
| 409 | Core::HID::NpadBatteryLevel battery_level_dual{}; | ||
| 410 | Core::HID::NpadBatteryLevel battery_level_left{}; | ||
| 411 | Core::HID::NpadBatteryLevel battery_level_right{}; | ||
| 412 | AppletFooterUiAttributes applet_footer_attributes{}; | ||
| 413 | AppletFooterUiType applet_footer_type{AppletFooterUiType::None}; | ||
| 414 | INSERT_PADDING_BYTES(0x5B); // Reserved | ||
| 415 | INSERT_PADDING_BYTES(0x20); // Unknown | ||
| 416 | Lifo<NpadGcTriggerState, hid_entry_count> gc_trigger_lifo{}; | ||
| 417 | NpadLarkType lark_type_l_and_main{}; | ||
| 418 | NpadLarkType lark_type_r{}; | ||
| 419 | NpadLuciaType lucia_type{}; | ||
| 420 | NpadLagonType lagon_type{}; | ||
| 421 | NpadLagerType lager_type{}; | ||
| 422 | Core::HID::SixAxisSensorProperties sixaxis_fullkey_properties; | ||
| 423 | Core::HID::SixAxisSensorProperties sixaxis_handheld_properties; | ||
| 424 | Core::HID::SixAxisSensorProperties sixaxis_dual_left_properties; | ||
| 425 | Core::HID::SixAxisSensorProperties sixaxis_dual_right_properties; | ||
| 426 | Core::HID::SixAxisSensorProperties sixaxis_left_properties; | ||
| 427 | Core::HID::SixAxisSensorProperties sixaxis_right_properties; | ||
| 428 | INSERT_PADDING_BYTES(0xc06); // Unknown | ||
| 429 | }; | ||
| 430 | static_assert(sizeof(NpadInternalState) == 0x5000, "NpadInternalState is an invalid size"); | ||
| 431 | |||
| 432 | struct VibrationData { | 142 | struct VibrationData { |
| 433 | bool device_mounted{}; | 143 | bool device_mounted{}; |
| 434 | Core::HID::VibrationValue latest_vibration_value{}; | 144 | Core::HID::VibrationValue latest_vibration_value{}; |
| @@ -479,7 +189,7 @@ private: | |||
| 479 | 189 | ||
| 480 | std::atomic<u64> press_state{}; | 190 | std::atomic<u64> press_state{}; |
| 481 | 191 | ||
| 482 | std::array<NpadControllerData, NPAD_COUNT> controller_data{}; | 192 | std::array<NpadControllerData, NpadCount> controller_data{}; |
| 483 | KernelHelpers::ServiceContext& service_context; | 193 | KernelHelpers::ServiceContext& service_context; |
| 484 | std::mutex mutex; | 194 | std::mutex mutex; |
| 485 | std::vector<Core::HID::NpadIdType> supported_npad_id_types{}; | 195 | std::vector<Core::HID::NpadIdType> supported_npad_id_types{}; |
diff --git a/src/core/hle/service/hid/controllers/palma.cpp b/src/core/hle/service/hid/controllers/palma.cpp index 588ff9d62..aa0454b5e 100644 --- a/src/core/hle/service/hid/controllers/palma.cpp +++ b/src/core/hle/service/hid/controllers/palma.cpp | |||
| @@ -12,8 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | namespace Service::HID { | 13 | namespace Service::HID { |
| 14 | 14 | ||
| 15 | Palma::Palma(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_, | 15 | Palma::Palma(Core::HID::HIDCore& hid_core_, KernelHelpers::ServiceContext& service_context_) |
| 16 | KernelHelpers::ServiceContext& service_context_) | ||
| 17 | : ControllerBase{hid_core_}, service_context{service_context_} { | 16 | : ControllerBase{hid_core_}, service_context{service_context_} { |
| 18 | controller = hid_core.GetEmulatedController(Core::HID::NpadIdType::Other); | 17 | controller = hid_core.GetEmulatedController(Core::HID::NpadIdType::Other); |
| 19 | operation_complete_event = service_context.CreateEvent("hid:PalmaOperationCompleteEvent"); | 18 | operation_complete_event = service_context.CreateEvent("hid:PalmaOperationCompleteEvent"); |
diff --git a/src/core/hle/service/hid/controllers/palma.h b/src/core/hle/service/hid/controllers/palma.h index a6047f36a..73884230d 100644 --- a/src/core/hle/service/hid/controllers/palma.h +++ b/src/core/hle/service/hid/controllers/palma.h | |||
| @@ -97,8 +97,7 @@ public: | |||
| 97 | static_assert(sizeof(PalmaConnectionHandle) == 0x8, | 97 | static_assert(sizeof(PalmaConnectionHandle) == 0x8, |
| 98 | "PalmaConnectionHandle has incorrect size."); | 98 | "PalmaConnectionHandle has incorrect size."); |
| 99 | 99 | ||
| 100 | explicit Palma(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_, | 100 | explicit Palma(Core::HID::HIDCore& hid_core_, KernelHelpers::ServiceContext& service_context_); |
| 101 | KernelHelpers::ServiceContext& service_context_); | ||
| 102 | ~Palma() override; | 101 | ~Palma() override; |
| 103 | 102 | ||
| 104 | // Called when the controller is initialized | 103 | // Called when the controller is initialized |
diff --git a/src/core/hle/service/hid/controllers/shared_memory_format.h b/src/core/hle/service/hid/controllers/shared_memory_format.h new file mode 100644 index 000000000..2986c113e --- /dev/null +++ b/src/core/hle/service/hid/controllers/shared_memory_format.h | |||
| @@ -0,0 +1,240 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "common/common_funcs.h" | ||
| 7 | #include "common/common_types.h" | ||
| 8 | #include "common/vector_math.h" | ||
| 9 | #include "core/hid/hid_types.h" | ||
| 10 | #include "core/hle/service/hid//controllers/types/debug_pad_types.h" | ||
| 11 | #include "core/hle/service/hid//controllers/types/keyboard_types.h" | ||
| 12 | #include "core/hle/service/hid//controllers/types/mouse_types.h" | ||
| 13 | #include "core/hle/service/hid//controllers/types/npad_types.h" | ||
| 14 | #include "core/hle/service/hid//controllers/types/touch_types.h" | ||
| 15 | #include "core/hle/service/hid/ring_lifo.h" | ||
| 16 | |||
| 17 | namespace Service::HID { | ||
| 18 | static const std::size_t HidEntryCount = 17; | ||
| 19 | |||
| 20 | struct CommonHeader { | ||
| 21 | s64 timestamp{}; | ||
| 22 | s64 total_entry_count{}; | ||
| 23 | s64 last_entry_index{}; | ||
| 24 | s64 entry_count{}; | ||
| 25 | }; | ||
| 26 | static_assert(sizeof(CommonHeader) == 0x20, "CommonHeader is an invalid size"); | ||
| 27 | |||
| 28 | // This is nn::hid::detail::DebugPadSharedMemoryFormat | ||
| 29 | struct DebugPadSharedMemoryFormat { | ||
| 30 | // This is nn::hid::detail::DebugPadLifo | ||
| 31 | Lifo<DebugPadState, HidEntryCount> debug_pad_lifo{}; | ||
| 32 | static_assert(sizeof(debug_pad_lifo) == 0x2C8, "debug_pad_lifo is an invalid size"); | ||
| 33 | INSERT_PADDING_WORDS(0x4E); | ||
| 34 | }; | ||
| 35 | static_assert(sizeof(DebugPadSharedMemoryFormat) == 0x400, | ||
| 36 | "DebugPadSharedMemoryFormat is an invalid size"); | ||
| 37 | |||
| 38 | // This is nn::hid::detail::TouchScreenSharedMemoryFormat | ||
| 39 | struct TouchScreenSharedMemoryFormat { | ||
| 40 | // This is nn::hid::detail::TouchScreenLifo | ||
| 41 | Lifo<TouchScreenState, HidEntryCount> touch_screen_lifo{}; | ||
| 42 | static_assert(sizeof(touch_screen_lifo) == 0x2C38, "touch_screen_lifo is an invalid size"); | ||
| 43 | INSERT_PADDING_WORDS(0xF2); | ||
| 44 | }; | ||
| 45 | static_assert(sizeof(TouchScreenSharedMemoryFormat) == 0x3000, | ||
| 46 | "TouchScreenSharedMemoryFormat is an invalid size"); | ||
| 47 | |||
| 48 | // This is nn::hid::detail::MouseSharedMemoryFormat | ||
| 49 | struct MouseSharedMemoryFormat { | ||
| 50 | // This is nn::hid::detail::MouseLifo | ||
| 51 | Lifo<Core::HID::MouseState, HidEntryCount> mouse_lifo{}; | ||
| 52 | static_assert(sizeof(mouse_lifo) == 0x350, "mouse_lifo is an invalid size"); | ||
| 53 | INSERT_PADDING_WORDS(0x2C); | ||
| 54 | }; | ||
| 55 | static_assert(sizeof(MouseSharedMemoryFormat) == 0x400, | ||
| 56 | "MouseSharedMemoryFormat is an invalid size"); | ||
| 57 | |||
| 58 | // This is nn::hid::detail::KeyboardSharedMemoryFormat | ||
| 59 | struct KeyboardSharedMemoryFormat { | ||
| 60 | // This is nn::hid::detail::KeyboardLifo | ||
| 61 | Lifo<KeyboardState, HidEntryCount> keyboard_lifo{}; | ||
| 62 | static_assert(sizeof(keyboard_lifo) == 0x3D8, "keyboard_lifo is an invalid size"); | ||
| 63 | INSERT_PADDING_WORDS(0xA); | ||
| 64 | }; | ||
| 65 | static_assert(sizeof(KeyboardSharedMemoryFormat) == 0x400, | ||
| 66 | "KeyboardSharedMemoryFormat is an invalid size"); | ||
| 67 | |||
| 68 | // This is nn::hid::detail::DigitizerSharedMemoryFormat | ||
| 69 | struct DigitizerSharedMemoryFormat { | ||
| 70 | CommonHeader header; | ||
| 71 | INSERT_PADDING_BYTES(0xFE0); | ||
| 72 | }; | ||
| 73 | static_assert(sizeof(DigitizerSharedMemoryFormat) == 0x1000, | ||
| 74 | "DigitizerSharedMemoryFormat is an invalid size"); | ||
| 75 | |||
| 76 | // This is nn::hid::detail::HomeButtonSharedMemoryFormat | ||
| 77 | struct HomeButtonSharedMemoryFormat { | ||
| 78 | CommonHeader header; | ||
| 79 | INSERT_PADDING_BYTES(0x1E0); | ||
| 80 | }; | ||
| 81 | static_assert(sizeof(HomeButtonSharedMemoryFormat) == 0x200, | ||
| 82 | "HomeButtonSharedMemoryFormat is an invalid size"); | ||
| 83 | |||
| 84 | // This is nn::hid::detail::SleepButtonSharedMemoryFormat | ||
| 85 | struct SleepButtonSharedMemoryFormat { | ||
| 86 | CommonHeader header; | ||
| 87 | INSERT_PADDING_BYTES(0x1E0); | ||
| 88 | }; | ||
| 89 | static_assert(sizeof(SleepButtonSharedMemoryFormat) == 0x200, | ||
| 90 | "SleepButtonSharedMemoryFormat is an invalid size"); | ||
| 91 | |||
| 92 | // This is nn::hid::detail::CaptureButtonSharedMemoryFormat | ||
| 93 | struct CaptureButtonSharedMemoryFormat { | ||
| 94 | CommonHeader header; | ||
| 95 | INSERT_PADDING_BYTES(0x1E0); | ||
| 96 | }; | ||
| 97 | static_assert(sizeof(CaptureButtonSharedMemoryFormat) == 0x200, | ||
| 98 | "CaptureButtonSharedMemoryFormat is an invalid size"); | ||
| 99 | |||
| 100 | // This is nn::hid::detail::InputDetectorSharedMemoryFormat | ||
| 101 | struct InputDetectorSharedMemoryFormat { | ||
| 102 | CommonHeader header; | ||
| 103 | INSERT_PADDING_BYTES(0x7E0); | ||
| 104 | }; | ||
| 105 | static_assert(sizeof(InputDetectorSharedMemoryFormat) == 0x800, | ||
| 106 | "InputDetectorSharedMemoryFormat is an invalid size"); | ||
| 107 | |||
| 108 | // This is nn::hid::detail::UniquePadSharedMemoryFormat | ||
| 109 | struct UniquePadSharedMemoryFormat { | ||
| 110 | CommonHeader header; | ||
| 111 | INSERT_PADDING_BYTES(0x3FE0); | ||
| 112 | }; | ||
| 113 | static_assert(sizeof(UniquePadSharedMemoryFormat) == 0x4000, | ||
| 114 | "UniquePadSharedMemoryFormat is an invalid size"); | ||
| 115 | |||
| 116 | // This is nn::hid::detail::NpadSixAxisSensorLifo | ||
| 117 | struct NpadSixAxisSensorLifo { | ||
| 118 | Lifo<Core::HID::SixAxisSensorState, HidEntryCount> lifo; | ||
| 119 | }; | ||
| 120 | |||
| 121 | // This is nn::hid::detail::NpadInternalState | ||
| 122 | struct NpadInternalState { | ||
| 123 | Core::HID::NpadStyleTag style_tag{Core::HID::NpadStyleSet::None}; | ||
| 124 | NpadJoyAssignmentMode assignment_mode{NpadJoyAssignmentMode::Dual}; | ||
| 125 | NpadFullKeyColorState fullkey_color{}; | ||
| 126 | NpadJoyColorState joycon_color{}; | ||
| 127 | Lifo<NPadGenericState, HidEntryCount> fullkey_lifo{}; | ||
| 128 | Lifo<NPadGenericState, HidEntryCount> handheld_lifo{}; | ||
| 129 | Lifo<NPadGenericState, HidEntryCount> joy_dual_lifo{}; | ||
| 130 | Lifo<NPadGenericState, HidEntryCount> joy_left_lifo{}; | ||
| 131 | Lifo<NPadGenericState, HidEntryCount> joy_right_lifo{}; | ||
| 132 | Lifo<NPadGenericState, HidEntryCount> palma_lifo{}; | ||
| 133 | Lifo<NPadGenericState, HidEntryCount> system_ext_lifo{}; | ||
| 134 | NpadSixAxisSensorLifo sixaxis_fullkey_lifo{}; | ||
| 135 | NpadSixAxisSensorLifo sixaxis_handheld_lifo{}; | ||
| 136 | NpadSixAxisSensorLifo sixaxis_dual_left_lifo{}; | ||
| 137 | NpadSixAxisSensorLifo sixaxis_dual_right_lifo{}; | ||
| 138 | NpadSixAxisSensorLifo sixaxis_left_lifo{}; | ||
| 139 | NpadSixAxisSensorLifo sixaxis_right_lifo{}; | ||
| 140 | DeviceType device_type{}; | ||
| 141 | INSERT_PADDING_BYTES(0x4); // Reserved | ||
| 142 | NPadSystemProperties system_properties{}; | ||
| 143 | NpadSystemButtonProperties button_properties{}; | ||
| 144 | Core::HID::NpadBatteryLevel battery_level_dual{}; | ||
| 145 | Core::HID::NpadBatteryLevel battery_level_left{}; | ||
| 146 | Core::HID::NpadBatteryLevel battery_level_right{}; | ||
| 147 | AppletFooterUiAttributes applet_footer_attributes{}; | ||
| 148 | AppletFooterUiType applet_footer_type{AppletFooterUiType::None}; | ||
| 149 | INSERT_PADDING_BYTES(0x5B); // Reserved | ||
| 150 | INSERT_PADDING_BYTES(0x20); // Unknown | ||
| 151 | Lifo<NpadGcTriggerState, HidEntryCount> gc_trigger_lifo{}; | ||
| 152 | NpadLarkType lark_type_l_and_main{}; | ||
| 153 | NpadLarkType lark_type_r{}; | ||
| 154 | NpadLuciaType lucia_type{}; | ||
| 155 | NpadLagerType lager_type{}; | ||
| 156 | Core::HID::SixAxisSensorProperties sixaxis_fullkey_properties; | ||
| 157 | Core::HID::SixAxisSensorProperties sixaxis_handheld_properties; | ||
| 158 | Core::HID::SixAxisSensorProperties sixaxis_dual_left_properties; | ||
| 159 | Core::HID::SixAxisSensorProperties sixaxis_dual_right_properties; | ||
| 160 | Core::HID::SixAxisSensorProperties sixaxis_left_properties; | ||
| 161 | Core::HID::SixAxisSensorProperties sixaxis_right_properties; | ||
| 162 | }; | ||
| 163 | static_assert(sizeof(NpadInternalState) == 0x43F8, "NpadInternalState is an invalid size"); | ||
| 164 | |||
| 165 | // This is nn::hid::detail::NpadSharedMemoryEntry | ||
| 166 | struct NpadSharedMemoryEntry { | ||
| 167 | NpadInternalState internal_state; | ||
| 168 | INSERT_PADDING_BYTES(0xC08); | ||
| 169 | }; | ||
| 170 | static_assert(sizeof(NpadSharedMemoryEntry) == 0x5000, "NpadSharedMemoryEntry is an invalid size"); | ||
| 171 | |||
| 172 | // This is nn::hid::detail::NpadSharedMemoryFormat | ||
| 173 | struct NpadSharedMemoryFormat { | ||
| 174 | std::array<NpadSharedMemoryEntry, NpadCount> npad_entry; | ||
| 175 | }; | ||
| 176 | static_assert(sizeof(NpadSharedMemoryFormat) == 0x32000, | ||
| 177 | "NpadSharedMemoryFormat is an invalid size"); | ||
| 178 | |||
| 179 | // This is nn::hid::detail::GestureSharedMemoryFormat | ||
| 180 | struct GestureSharedMemoryFormat { | ||
| 181 | // This is nn::hid::detail::GestureLifo | ||
| 182 | Lifo<GestureState, HidEntryCount> gesture_lifo{}; | ||
| 183 | static_assert(sizeof(gesture_lifo) == 0x708, "gesture_lifo is an invalid size"); | ||
| 184 | INSERT_PADDING_WORDS(0x3E); | ||
| 185 | }; | ||
| 186 | static_assert(sizeof(GestureSharedMemoryFormat) == 0x800, | ||
| 187 | "GestureSharedMemoryFormat is an invalid size"); | ||
| 188 | |||
| 189 | // This is nn::hid::detail::ConsoleSixAxisSensorSharedMemoryFormat | ||
| 190 | struct ConsoleSixAxisSensorSharedMemoryFormat { | ||
| 191 | u64 sampling_number{}; | ||
| 192 | bool is_seven_six_axis_sensor_at_rest{}; | ||
| 193 | INSERT_PADDING_BYTES(3); // padding | ||
| 194 | f32 verticalization_error{}; | ||
| 195 | Common::Vec3f gyro_bias{}; | ||
| 196 | INSERT_PADDING_BYTES(4); // padding | ||
| 197 | }; | ||
| 198 | static_assert(sizeof(ConsoleSixAxisSensorSharedMemoryFormat) == 0x20, | ||
| 199 | "ConsoleSixAxisSensorSharedMemoryFormat is an invalid size"); | ||
| 200 | |||
| 201 | // This is nn::hid::detail::SharedMemoryFormat | ||
| 202 | struct SharedMemoryFormat { | ||
| 203 | void Initialize() {} | ||
| 204 | |||
| 205 | DebugPadSharedMemoryFormat debug_pad; | ||
| 206 | TouchScreenSharedMemoryFormat touch_screen; | ||
| 207 | MouseSharedMemoryFormat mouse; | ||
| 208 | KeyboardSharedMemoryFormat keyboard; | ||
| 209 | DigitizerSharedMemoryFormat digitizer; | ||
| 210 | HomeButtonSharedMemoryFormat home_button; | ||
| 211 | SleepButtonSharedMemoryFormat sleep_button; | ||
| 212 | CaptureButtonSharedMemoryFormat capture_button; | ||
| 213 | InputDetectorSharedMemoryFormat input_detector; | ||
| 214 | UniquePadSharedMemoryFormat unique_pad; | ||
| 215 | NpadSharedMemoryFormat npad; | ||
| 216 | GestureSharedMemoryFormat gesture; | ||
| 217 | ConsoleSixAxisSensorSharedMemoryFormat console; | ||
| 218 | INSERT_PADDING_BYTES(0x19E0); | ||
| 219 | MouseSharedMemoryFormat debug_mouse; | ||
| 220 | INSERT_PADDING_BYTES(0x2000); | ||
| 221 | }; | ||
| 222 | static_assert(offsetof(SharedMemoryFormat, debug_pad) == 0x0, "debug_pad has wrong offset"); | ||
| 223 | static_assert(offsetof(SharedMemoryFormat, touch_screen) == 0x400, "touch_screen has wrong offset"); | ||
| 224 | static_assert(offsetof(SharedMemoryFormat, mouse) == 0x3400, "mouse has wrong offset"); | ||
| 225 | static_assert(offsetof(SharedMemoryFormat, keyboard) == 0x3800, "keyboard has wrong offset"); | ||
| 226 | static_assert(offsetof(SharedMemoryFormat, digitizer) == 0x3C00, "digitizer has wrong offset"); | ||
| 227 | static_assert(offsetof(SharedMemoryFormat, home_button) == 0x4C00, "home_button has wrong offset"); | ||
| 228 | static_assert(offsetof(SharedMemoryFormat, sleep_button) == 0x4E00, | ||
| 229 | "sleep_button has wrong offset"); | ||
| 230 | static_assert(offsetof(SharedMemoryFormat, capture_button) == 0x5000, | ||
| 231 | "capture_button has wrong offset"); | ||
| 232 | static_assert(offsetof(SharedMemoryFormat, input_detector) == 0x5200, | ||
| 233 | "input_detector has wrong offset"); | ||
| 234 | static_assert(offsetof(SharedMemoryFormat, npad) == 0x9A00, "npad has wrong offset"); | ||
| 235 | static_assert(offsetof(SharedMemoryFormat, gesture) == 0x3BA00, "gesture has wrong offset"); | ||
| 236 | static_assert(offsetof(SharedMemoryFormat, console) == 0x3C200, "console has wrong offset"); | ||
| 237 | static_assert(offsetof(SharedMemoryFormat, debug_mouse) == 0x3DC00, "debug_mouse has wrong offset"); | ||
| 238 | static_assert(sizeof(SharedMemoryFormat) == 0x40000, "SharedMemoryFormat is an invalid size"); | ||
| 239 | |||
| 240 | } // namespace Service::HID | ||
diff --git a/src/core/hle/service/hid/controllers/shared_memory_holder.cpp b/src/core/hle/service/hid/controllers/shared_memory_holder.cpp new file mode 100644 index 000000000..51581188e --- /dev/null +++ b/src/core/hle/service/hid/controllers/shared_memory_holder.cpp | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 3 | |||
| 4 | #include "core/core.h" | ||
| 5 | #include "core/hle/kernel/k_shared_memory.h" | ||
| 6 | #include "core/hle/service/hid/controllers/shared_memory_format.h" | ||
| 7 | #include "core/hle/service/hid/controllers/shared_memory_holder.h" | ||
| 8 | #include "core/hle/service/hid/errors.h" | ||
| 9 | |||
| 10 | namespace Service::HID { | ||
| 11 | SharedMemoryHolder::SharedMemoryHolder() {} | ||
| 12 | |||
| 13 | SharedMemoryHolder::~SharedMemoryHolder() { | ||
| 14 | Finalize(); | ||
| 15 | } | ||
| 16 | |||
| 17 | Result SharedMemoryHolder::Initialize(Core::System& system) { | ||
| 18 | shared_memory = Kernel::KSharedMemory::Create(system.Kernel()); | ||
| 19 | const Result result = shared_memory->Initialize( | ||
| 20 | system.DeviceMemory(), nullptr, Kernel::Svc::MemoryPermission::None, | ||
| 21 | Kernel::Svc::MemoryPermission::Read, sizeof(SharedMemoryFormat)); | ||
| 22 | if (result.IsError()) { | ||
| 23 | return result; | ||
| 24 | } | ||
| 25 | Kernel::KSharedMemory::Register(system.Kernel(), shared_memory); | ||
| 26 | |||
| 27 | is_created = true; | ||
| 28 | is_mapped = true; | ||
| 29 | address = std::construct_at(reinterpret_cast<SharedMemoryFormat*>(shared_memory->GetPointer())); | ||
| 30 | return ResultSuccess; | ||
| 31 | } | ||
| 32 | |||
| 33 | void SharedMemoryHolder::Finalize() { | ||
| 34 | if (address != nullptr) { | ||
| 35 | shared_memory->Close(); | ||
| 36 | } | ||
| 37 | is_created = false; | ||
| 38 | is_mapped = false; | ||
| 39 | address = nullptr; | ||
| 40 | } | ||
| 41 | |||
| 42 | bool SharedMemoryHolder::IsMapped() { | ||
| 43 | return is_mapped; | ||
| 44 | } | ||
| 45 | |||
| 46 | SharedMemoryFormat* SharedMemoryHolder::GetAddress() { | ||
| 47 | return address; | ||
| 48 | } | ||
| 49 | |||
| 50 | Kernel::KSharedMemory* SharedMemoryHolder::GetHandle() { | ||
| 51 | return shared_memory; | ||
| 52 | } | ||
| 53 | } // namespace Service::HID | ||
diff --git a/src/core/hle/service/hid/controllers/shared_memory_holder.h b/src/core/hle/service/hid/controllers/shared_memory_holder.h new file mode 100644 index 000000000..943407c00 --- /dev/null +++ b/src/core/hle/service/hid/controllers/shared_memory_holder.h | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "core/hle/result.h" | ||
| 7 | |||
| 8 | namespace Core { | ||
| 9 | class System; | ||
| 10 | } | ||
| 11 | |||
| 12 | namespace Kernel { | ||
| 13 | class KSharedMemory; | ||
| 14 | } | ||
| 15 | |||
| 16 | namespace Service::HID { | ||
| 17 | struct SharedMemoryFormat; | ||
| 18 | |||
| 19 | // This is nn::hid::detail::SharedMemoryHolder | ||
| 20 | class SharedMemoryHolder { | ||
| 21 | public: | ||
| 22 | SharedMemoryHolder(); | ||
| 23 | ~SharedMemoryHolder(); | ||
| 24 | |||
| 25 | Result Initialize(Core::System& system); | ||
| 26 | void Finalize(); | ||
| 27 | |||
| 28 | bool IsMapped(); | ||
| 29 | SharedMemoryFormat* GetAddress(); | ||
| 30 | Kernel::KSharedMemory* GetHandle(); | ||
| 31 | |||
| 32 | private: | ||
| 33 | bool is_owner{}; | ||
| 34 | bool is_created{}; | ||
| 35 | bool is_mapped{}; | ||
| 36 | INSERT_PADDING_BYTES(0x5); | ||
| 37 | Kernel::KSharedMemory* shared_memory; | ||
| 38 | INSERT_PADDING_BYTES(0x38); | ||
| 39 | SharedMemoryFormat* address = nullptr; | ||
| 40 | }; | ||
| 41 | // Correct size is 0x50 bytes | ||
| 42 | static_assert(sizeof(SharedMemoryHolder) == 0x50, "SharedMemoryHolder is an invalid size"); | ||
| 43 | |||
| 44 | } // namespace Service::HID | ||
diff --git a/src/core/hle/service/hid/controllers/six_axis.cpp b/src/core/hle/service/hid/controllers/six_axis.cpp index 3d24a5c04..36b72f9ea 100644 --- a/src/core/hle/service/hid/controllers/six_axis.cpp +++ b/src/core/hle/service/hid/controllers/six_axis.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include "core/hid/emulated_controller.h" | 6 | #include "core/hid/emulated_controller.h" |
| 7 | #include "core/hid/hid_core.h" | 7 | #include "core/hid/hid_core.h" |
| 8 | #include "core/hle/service/hid/controllers/npad.h" | 8 | #include "core/hle/service/hid/controllers/npad.h" |
| 9 | #include "core/hle/service/hid/controllers/shared_memory_format.h" | ||
| 9 | #include "core/hle/service/hid/controllers/six_axis.h" | 10 | #include "core/hle/service/hid/controllers/six_axis.h" |
| 10 | #include "core/hle/service/hid/errors.h" | 11 | #include "core/hle/service/hid/errors.h" |
| 11 | #include "core/hle/service/hid/hid_util.h" | 12 | #include "core/hle/service/hid/hid_util.h" |
| @@ -132,30 +133,30 @@ void SixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing) { | |||
| 132 | } | 133 | } |
| 133 | 134 | ||
| 134 | sixaxis_fullkey_state.sampling_number = | 135 | sixaxis_fullkey_state.sampling_number = |
| 135 | sixaxis_fullkey_lifo.ReadCurrentEntry().state.sampling_number + 1; | 136 | sixaxis_fullkey_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1; |
| 136 | sixaxis_handheld_state.sampling_number = | 137 | sixaxis_handheld_state.sampling_number = |
| 137 | sixaxis_handheld_lifo.ReadCurrentEntry().state.sampling_number + 1; | 138 | sixaxis_handheld_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1; |
| 138 | sixaxis_dual_left_state.sampling_number = | 139 | sixaxis_dual_left_state.sampling_number = |
| 139 | sixaxis_dual_left_lifo.ReadCurrentEntry().state.sampling_number + 1; | 140 | sixaxis_dual_left_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1; |
| 140 | sixaxis_dual_right_state.sampling_number = | 141 | sixaxis_dual_right_state.sampling_number = |
| 141 | sixaxis_dual_right_lifo.ReadCurrentEntry().state.sampling_number + 1; | 142 | sixaxis_dual_right_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1; |
| 142 | sixaxis_left_lifo_state.sampling_number = | 143 | sixaxis_left_lifo_state.sampling_number = |
| 143 | sixaxis_left_lifo.ReadCurrentEntry().state.sampling_number + 1; | 144 | sixaxis_left_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1; |
| 144 | sixaxis_right_lifo_state.sampling_number = | 145 | sixaxis_right_lifo_state.sampling_number = |
| 145 | sixaxis_right_lifo.ReadCurrentEntry().state.sampling_number + 1; | 146 | sixaxis_right_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1; |
| 146 | 147 | ||
| 147 | if (IndexToNpadIdType(i) == Core::HID::NpadIdType::Handheld) { | 148 | if (IndexToNpadIdType(i) == Core::HID::NpadIdType::Handheld) { |
| 148 | // This buffer only is updated on handheld on HW | 149 | // This buffer only is updated on handheld on HW |
| 149 | sixaxis_handheld_lifo.WriteNextEntry(sixaxis_handheld_state); | 150 | sixaxis_handheld_lifo.lifo.WriteNextEntry(sixaxis_handheld_state); |
| 150 | } else { | 151 | } else { |
| 151 | // Handheld doesn't update this buffer on HW | 152 | // Handheld doesn't update this buffer on HW |
| 152 | sixaxis_fullkey_lifo.WriteNextEntry(sixaxis_fullkey_state); | 153 | sixaxis_fullkey_lifo.lifo.WriteNextEntry(sixaxis_fullkey_state); |
| 153 | } | 154 | } |
| 154 | 155 | ||
| 155 | sixaxis_dual_left_lifo.WriteNextEntry(sixaxis_dual_left_state); | 156 | sixaxis_dual_left_lifo.lifo.WriteNextEntry(sixaxis_dual_left_state); |
| 156 | sixaxis_dual_right_lifo.WriteNextEntry(sixaxis_dual_right_state); | 157 | sixaxis_dual_right_lifo.lifo.WriteNextEntry(sixaxis_dual_right_state); |
| 157 | sixaxis_left_lifo.WriteNextEntry(sixaxis_left_lifo_state); | 158 | sixaxis_left_lifo.lifo.WriteNextEntry(sixaxis_left_lifo_state); |
| 158 | sixaxis_right_lifo.WriteNextEntry(sixaxis_right_lifo_state); | 159 | sixaxis_right_lifo.lifo.WriteNextEntry(sixaxis_right_lifo_state); |
| 159 | } | 160 | } |
| 160 | } | 161 | } |
| 161 | 162 | ||
diff --git a/src/core/hle/service/hid/controllers/stubbed.cpp b/src/core/hle/service/hid/controllers/stubbed.cpp index 9e2f3ab21..e2a5f5d79 100644 --- a/src/core/hle/service/hid/controllers/stubbed.cpp +++ b/src/core/hle/service/hid/controllers/stubbed.cpp | |||
| @@ -1,18 +1,15 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include <cstring> | ||
| 5 | #include "common/common_types.h" | ||
| 6 | #include "core/core_timing.h" | 4 | #include "core/core_timing.h" |
| 7 | #include "core/hid/hid_core.h" | 5 | #include "core/hle/service/hid/controllers/shared_memory_format.h" |
| 8 | #include "core/hle/service/hid/controllers/stubbed.h" | 6 | #include "core/hle/service/hid/controllers/stubbed.h" |
| 9 | 7 | ||
| 10 | namespace Service::HID { | 8 | namespace Service::HID { |
| 11 | 9 | ||
| 12 | Controller_Stubbed::Controller_Stubbed(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_) | 10 | Controller_Stubbed::Controller_Stubbed(Core::HID::HIDCore& hid_core_, |
| 13 | : ControllerBase{hid_core_} { | 11 | CommonHeader& ring_lifo_header) |
| 14 | raw_shared_memory = raw_shared_memory_; | 12 | : ControllerBase{hid_core_}, header{ring_lifo_header} {} |
| 15 | } | ||
| 16 | 13 | ||
| 17 | Controller_Stubbed::~Controller_Stubbed() = default; | 14 | Controller_Stubbed::~Controller_Stubbed() = default; |
| 18 | 15 | ||
| @@ -25,18 +22,10 @@ void Controller_Stubbed::OnUpdate(const Core::Timing::CoreTiming& core_timing) { | |||
| 25 | return; | 22 | return; |
| 26 | } | 23 | } |
| 27 | 24 | ||
| 28 | CommonHeader header{}; | ||
| 29 | header.timestamp = core_timing.GetGlobalTimeNs().count(); | 25 | header.timestamp = core_timing.GetGlobalTimeNs().count(); |
| 30 | header.total_entry_count = 17; | 26 | header.total_entry_count = 17; |
| 31 | header.entry_count = 0; | 27 | header.entry_count = 0; |
| 32 | header.last_entry_index = 0; | 28 | header.last_entry_index = 0; |
| 33 | |||
| 34 | std::memcpy(raw_shared_memory + common_offset, &header, sizeof(CommonHeader)); | ||
| 35 | } | ||
| 36 | |||
| 37 | void Controller_Stubbed::SetCommonHeaderOffset(std::size_t off) { | ||
| 38 | common_offset = off; | ||
| 39 | smart_update = true; | ||
| 40 | } | 29 | } |
| 41 | 30 | ||
| 42 | } // namespace Service::HID | 31 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/controllers/stubbed.h b/src/core/hle/service/hid/controllers/stubbed.h index 1483a968e..d2052fb17 100644 --- a/src/core/hle/service/hid/controllers/stubbed.h +++ b/src/core/hle/service/hid/controllers/stubbed.h | |||
| @@ -3,13 +3,14 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "common/common_types.h" | ||
| 7 | #include "core/hle/service/hid/controllers/controller_base.h" | 6 | #include "core/hle/service/hid/controllers/controller_base.h" |
| 8 | 7 | ||
| 9 | namespace Service::HID { | 8 | namespace Service::HID { |
| 9 | struct CommonHeader; | ||
| 10 | |||
| 10 | class Controller_Stubbed final : public ControllerBase { | 11 | class Controller_Stubbed final : public ControllerBase { |
| 11 | public: | 12 | public: |
| 12 | explicit Controller_Stubbed(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_); | 13 | explicit Controller_Stubbed(Core::HID::HIDCore& hid_core_, CommonHeader& ring_lifo_header); |
| 13 | ~Controller_Stubbed() override; | 14 | ~Controller_Stubbed() override; |
| 14 | 15 | ||
| 15 | // Called when the controller is initialized | 16 | // Called when the controller is initialized |
| @@ -21,19 +22,8 @@ public: | |||
| 21 | // When the controller is requesting an update for the shared memory | 22 | // When the controller is requesting an update for the shared memory |
| 22 | void OnUpdate(const Core::Timing::CoreTiming& core_timing) override; | 23 | void OnUpdate(const Core::Timing::CoreTiming& core_timing) override; |
| 23 | 24 | ||
| 24 | void SetCommonHeaderOffset(std::size_t off); | ||
| 25 | |||
| 26 | private: | 25 | private: |
| 27 | struct CommonHeader { | 26 | CommonHeader& header; |
| 28 | s64 timestamp{}; | ||
| 29 | s64 total_entry_count{}; | ||
| 30 | s64 last_entry_index{}; | ||
| 31 | s64 entry_count{}; | ||
| 32 | }; | ||
| 33 | static_assert(sizeof(CommonHeader) == 0x20, "CommonHeader is an invalid size"); | ||
| 34 | |||
| 35 | u8* raw_shared_memory = nullptr; | ||
| 36 | bool smart_update{}; | 27 | bool smart_update{}; |
| 37 | std::size_t common_offset{}; | ||
| 38 | }; | 28 | }; |
| 39 | } // namespace Service::HID | 29 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp index fcd973414..469750006 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.cpp +++ b/src/core/hle/service/hid/controllers/touchscreen.cpp | |||
| @@ -2,26 +2,22 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include <algorithm> | 4 | #include <algorithm> |
| 5 | #include <cstring> | ||
| 6 | #include "common/common_types.h" | 5 | #include "common/common_types.h" |
| 7 | #include "common/settings.h" | 6 | #include "common/settings.h" |
| 8 | #include "core/core.h" | ||
| 9 | #include "core/core_timing.h" | 7 | #include "core/core_timing.h" |
| 10 | #include "core/frontend/emu_window.h" | 8 | #include "core/frontend/emu_window.h" |
| 11 | #include "core/hid/emulated_console.h" | 9 | #include "core/hid/emulated_console.h" |
| 12 | #include "core/hid/hid_core.h" | 10 | #include "core/hid/hid_core.h" |
| 11 | #include "core/hle/service/hid/controllers/shared_memory_format.h" | ||
| 13 | #include "core/hle/service/hid/controllers/touchscreen.h" | 12 | #include "core/hle/service/hid/controllers/touchscreen.h" |
| 14 | 13 | ||
| 15 | namespace Service::HID { | 14 | namespace Service::HID { |
| 16 | constexpr std::size_t SHARED_MEMORY_OFFSET = 0x400; | ||
| 17 | 15 | ||
| 18 | TouchScreen::TouchScreen(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_) | 16 | TouchScreen::TouchScreen(Core::HID::HIDCore& hid_core_, |
| 19 | : ControllerBase{hid_core_}, touchscreen_width(Layout::ScreenUndocked::Width), | 17 | TouchScreenSharedMemoryFormat& touch_shared_memory) |
| 18 | : ControllerBase{hid_core_}, shared_memory{touch_shared_memory}, | ||
| 19 | touchscreen_width(Layout::ScreenUndocked::Width), | ||
| 20 | touchscreen_height(Layout::ScreenUndocked::Height) { | 20 | touchscreen_height(Layout::ScreenUndocked::Height) { |
| 21 | static_assert(SHARED_MEMORY_OFFSET + sizeof(TouchSharedMemory) < shared_memory_size, | ||
| 22 | "TouchSharedMemory is bigger than the shared memory"); | ||
| 23 | shared_memory = std::construct_at( | ||
| 24 | reinterpret_cast<TouchSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET)); | ||
| 25 | console = hid_core.GetEmulatedConsole(); | 21 | console = hid_core.GetEmulatedConsole(); |
| 26 | } | 22 | } |
| 27 | 23 | ||
| @@ -32,11 +28,11 @@ void TouchScreen::OnInit() {} | |||
| 32 | void TouchScreen::OnRelease() {} | 28 | void TouchScreen::OnRelease() {} |
| 33 | 29 | ||
| 34 | void TouchScreen::OnUpdate(const Core::Timing::CoreTiming& core_timing) { | 30 | void TouchScreen::OnUpdate(const Core::Timing::CoreTiming& core_timing) { |
| 35 | shared_memory->touch_screen_lifo.timestamp = core_timing.GetGlobalTimeNs().count(); | 31 | shared_memory.touch_screen_lifo.timestamp = core_timing.GetGlobalTimeNs().count(); |
| 36 | 32 | ||
| 37 | if (!IsControllerActivated()) { | 33 | if (!IsControllerActivated()) { |
| 38 | shared_memory->touch_screen_lifo.buffer_count = 0; | 34 | shared_memory.touch_screen_lifo.buffer_count = 0; |
| 39 | shared_memory->touch_screen_lifo.buffer_tail = 0; | 35 | shared_memory.touch_screen_lifo.buffer_tail = 0; |
| 40 | return; | 36 | return; |
| 41 | } | 37 | } |
| 42 | 38 | ||
| @@ -86,7 +82,7 @@ void TouchScreen::OnUpdate(const Core::Timing::CoreTiming& core_timing) { | |||
| 86 | static_cast<std::size_t>(std::distance(active_fingers.begin(), end_iter)); | 82 | static_cast<std::size_t>(std::distance(active_fingers.begin(), end_iter)); |
| 87 | 83 | ||
| 88 | const u64 timestamp = static_cast<u64>(core_timing.GetGlobalTimeNs().count()); | 84 | const u64 timestamp = static_cast<u64>(core_timing.GetGlobalTimeNs().count()); |
| 89 | const auto& last_entry = shared_memory->touch_screen_lifo.ReadCurrentEntry().state; | 85 | const auto& last_entry = shared_memory.touch_screen_lifo.ReadCurrentEntry().state; |
| 90 | 86 | ||
| 91 | next_state.sampling_number = last_entry.sampling_number + 1; | 87 | next_state.sampling_number = last_entry.sampling_number + 1; |
| 92 | next_state.entry_count = static_cast<s32>(active_fingers_count); | 88 | next_state.entry_count = static_cast<s32>(active_fingers_count); |
| @@ -118,7 +114,7 @@ void TouchScreen::OnUpdate(const Core::Timing::CoreTiming& core_timing) { | |||
| 118 | } | 114 | } |
| 119 | } | 115 | } |
| 120 | 116 | ||
| 121 | shared_memory->touch_screen_lifo.WriteNextEntry(next_state); | 117 | shared_memory.touch_screen_lifo.WriteNextEntry(next_state); |
| 122 | } | 118 | } |
| 123 | 119 | ||
| 124 | void TouchScreen::SetTouchscreenDimensions(u32 width, u32 height) { | 120 | void TouchScreen::SetTouchscreenDimensions(u32 width, u32 height) { |
diff --git a/src/core/hle/service/hid/controllers/touchscreen.h b/src/core/hle/service/hid/controllers/touchscreen.h index 79f026a81..5b6305bfc 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.h +++ b/src/core/hle/service/hid/controllers/touchscreen.h | |||
| @@ -3,20 +3,23 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "common/common_funcs.h" | 6 | #include <array> |
| 7 | #include "common/common_types.h" | 7 | |
| 8 | #include "core/hid/hid_types.h" | 8 | #include "core/hid/hid_types.h" |
| 9 | #include "core/hle/service/hid/controllers/controller_base.h" | 9 | #include "core/hle/service/hid/controllers/controller_base.h" |
| 10 | #include "core/hle/service/hid/ring_lifo.h" | 10 | #include "core/hle/service/hid/controllers/types/touch_types.h" |
| 11 | 11 | ||
| 12 | namespace Core::HID { | 12 | namespace Core::HID { |
| 13 | class EmulatedConsole; | 13 | class EmulatedConsole; |
| 14 | } // namespace Core::HID | 14 | } // namespace Core::HID |
| 15 | 15 | ||
| 16 | namespace Service::HID { | 16 | namespace Service::HID { |
| 17 | struct TouchScreenSharedMemoryFormat; | ||
| 18 | |||
| 17 | class TouchScreen final : public ControllerBase { | 19 | class TouchScreen final : public ControllerBase { |
| 18 | public: | 20 | public: |
| 19 | explicit TouchScreen(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_); | 21 | explicit TouchScreen(Core::HID::HIDCore& hid_core_, |
| 22 | TouchScreenSharedMemoryFormat& touch_shared_memory); | ||
| 20 | ~TouchScreen() override; | 23 | ~TouchScreen() override; |
| 21 | 24 | ||
| 22 | // Called when the controller is initialized | 25 | // Called when the controller is initialized |
| @@ -31,27 +34,8 @@ public: | |||
| 31 | void SetTouchscreenDimensions(u32 width, u32 height); | 34 | void SetTouchscreenDimensions(u32 width, u32 height); |
| 32 | 35 | ||
| 33 | private: | 36 | private: |
| 34 | static constexpr std::size_t MAX_FINGERS = 16; | ||
| 35 | |||
| 36 | // This is nn::hid::TouchScreenState | ||
| 37 | struct TouchScreenState { | ||
| 38 | s64 sampling_number{}; | ||
| 39 | s32 entry_count{}; | ||
| 40 | INSERT_PADDING_BYTES(4); // Reserved | ||
| 41 | std::array<Core::HID::TouchState, MAX_FINGERS> states{}; | ||
| 42 | }; | ||
| 43 | static_assert(sizeof(TouchScreenState) == 0x290, "TouchScreenState is an invalid size"); | ||
| 44 | |||
| 45 | struct TouchSharedMemory { | ||
| 46 | // This is nn::hid::detail::TouchScreenLifo | ||
| 47 | Lifo<TouchScreenState, hid_entry_count> touch_screen_lifo{}; | ||
| 48 | static_assert(sizeof(touch_screen_lifo) == 0x2C38, "touch_screen_lifo is an invalid size"); | ||
| 49 | INSERT_PADDING_WORDS(0xF2); | ||
| 50 | }; | ||
| 51 | static_assert(sizeof(TouchSharedMemory) == 0x3000, "TouchSharedMemory is an invalid size"); | ||
| 52 | |||
| 53 | TouchScreenState next_state{}; | 37 | TouchScreenState next_state{}; |
| 54 | TouchSharedMemory* shared_memory = nullptr; | 38 | TouchScreenSharedMemoryFormat& shared_memory; |
| 55 | Core::HID::EmulatedConsole* console = nullptr; | 39 | Core::HID::EmulatedConsole* console = nullptr; |
| 56 | 40 | ||
| 57 | std::array<Core::HID::TouchFinger, MAX_FINGERS> fingers{}; | 41 | std::array<Core::HID::TouchFinger, MAX_FINGERS> fingers{}; |
diff --git a/src/core/hle/service/hid/controllers/types/debug_pad_types.h b/src/core/hle/service/hid/controllers/types/debug_pad_types.h new file mode 100644 index 000000000..a96171b62 --- /dev/null +++ b/src/core/hle/service/hid/controllers/types/debug_pad_types.h | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "common/bit_field.h" | ||
| 7 | #include "common/common_types.h" | ||
| 8 | #include "core/hid/hid_types.h" | ||
| 9 | |||
| 10 | namespace Service::HID { | ||
| 11 | |||
| 12 | // This is nn::hid::DebugPadAttribute | ||
| 13 | struct DebugPadAttribute { | ||
| 14 | union { | ||
| 15 | u32 raw{}; | ||
| 16 | BitField<0, 1, u32> connected; | ||
| 17 | }; | ||
| 18 | }; | ||
| 19 | static_assert(sizeof(DebugPadAttribute) == 0x4, "DebugPadAttribute is an invalid size"); | ||
| 20 | |||
| 21 | // This is nn::hid::DebugPadState | ||
| 22 | struct DebugPadState { | ||
| 23 | s64 sampling_number{}; | ||
| 24 | DebugPadAttribute attribute{}; | ||
| 25 | Core::HID::DebugPadButton pad_state{}; | ||
| 26 | Core::HID::AnalogStickState r_stick{}; | ||
| 27 | Core::HID::AnalogStickState l_stick{}; | ||
| 28 | }; | ||
| 29 | static_assert(sizeof(DebugPadState) == 0x20, "DebugPadState is an invalid state"); | ||
| 30 | |||
| 31 | } // namespace Service::HID | ||
diff --git a/src/core/hle/service/hid/controllers/types/gesture_types.h b/src/core/hle/service/hid/controllers/types/gesture_types.h new file mode 100644 index 000000000..b4f034cd3 --- /dev/null +++ b/src/core/hle/service/hid/controllers/types/gesture_types.h | |||
| @@ -0,0 +1,77 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <array> | ||
| 7 | #include "common/bit_field.h" | ||
| 8 | #include "common/common_types.h" | ||
| 9 | #include "common/point.h" | ||
| 10 | |||
| 11 | namespace Service::HID { | ||
| 12 | static constexpr size_t MAX_FINGERS = 16; | ||
| 13 | static constexpr size_t MAX_POINTS = 4; | ||
| 14 | |||
| 15 | // This is nn::hid::GestureType | ||
| 16 | enum class GestureType : u32 { | ||
| 17 | Idle, // Nothing touching the screen | ||
| 18 | Complete, // Set at the end of a touch event | ||
| 19 | Cancel, // Set when the number of fingers change | ||
| 20 | Touch, // A finger just touched the screen | ||
| 21 | Press, // Set if last type is touch and the finger hasn't moved | ||
| 22 | Tap, // Fast press then release | ||
| 23 | Pan, // All points moving together across the screen | ||
| 24 | Swipe, // Fast press movement and release of a single point | ||
| 25 | Pinch, // All points moving away/closer to the midpoint | ||
| 26 | Rotate, // All points rotating from the midpoint | ||
| 27 | }; | ||
| 28 | |||
| 29 | // This is nn::hid::GestureDirection | ||
| 30 | enum class GestureDirection : u32 { | ||
| 31 | None, | ||
| 32 | Left, | ||
| 33 | Up, | ||
| 34 | Right, | ||
| 35 | Down, | ||
| 36 | }; | ||
| 37 | |||
| 38 | // This is nn::hid::GestureAttribute | ||
| 39 | struct GestureAttribute { | ||
| 40 | union { | ||
| 41 | u32 raw{}; | ||
| 42 | |||
| 43 | BitField<4, 1, u32> is_new_touch; | ||
| 44 | BitField<8, 1, u32> is_double_tap; | ||
| 45 | }; | ||
| 46 | }; | ||
| 47 | static_assert(sizeof(GestureAttribute) == 4, "GestureAttribute is an invalid size"); | ||
| 48 | |||
| 49 | // This is nn::hid::GestureState | ||
| 50 | struct GestureState { | ||
| 51 | s64 sampling_number{}; | ||
| 52 | s64 detection_count{}; | ||
| 53 | GestureType type{GestureType::Idle}; | ||
| 54 | GestureDirection direction{GestureDirection::None}; | ||
| 55 | Common::Point<s32> pos{}; | ||
| 56 | Common::Point<s32> delta{}; | ||
| 57 | f32 vel_x{}; | ||
| 58 | f32 vel_y{}; | ||
| 59 | GestureAttribute attributes{}; | ||
| 60 | f32 scale{}; | ||
| 61 | f32 rotation_angle{}; | ||
| 62 | s32 point_count{}; | ||
| 63 | std::array<Common::Point<s32>, 4> points{}; | ||
| 64 | }; | ||
| 65 | static_assert(sizeof(GestureState) == 0x60, "GestureState is an invalid size"); | ||
| 66 | |||
| 67 | struct GestureProperties { | ||
| 68 | std::array<Common::Point<s32>, MAX_POINTS> points{}; | ||
| 69 | std::size_t active_points{}; | ||
| 70 | Common::Point<s32> mid_point{}; | ||
| 71 | s64 detection_count{}; | ||
| 72 | u64 delta_time{}; | ||
| 73 | f32 average_distance{}; | ||
| 74 | f32 angle{}; | ||
| 75 | }; | ||
| 76 | |||
| 77 | } // namespace Service::HID | ||
diff --git a/src/core/hle/service/hid/controllers/types/keyboard_types.h b/src/core/hle/service/hid/controllers/types/keyboard_types.h new file mode 100644 index 000000000..f44a536b9 --- /dev/null +++ b/src/core/hle/service/hid/controllers/types/keyboard_types.h | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "common/common_types.h" | ||
| 7 | #include "core/hid/hid_types.h" | ||
| 8 | |||
| 9 | namespace Service::HID { | ||
| 10 | |||
| 11 | // This is nn::hid::detail::KeyboardState | ||
| 12 | struct KeyboardState { | ||
| 13 | s64 sampling_number{}; | ||
| 14 | Core::HID::KeyboardModifier modifier{}; | ||
| 15 | Core::HID::KeyboardAttribute attribute{}; | ||
| 16 | Core::HID::KeyboardKey key{}; | ||
| 17 | }; | ||
| 18 | static_assert(sizeof(KeyboardState) == 0x30, "KeyboardState is an invalid size"); | ||
| 19 | |||
| 20 | } // namespace Service::HID | ||
diff --git a/src/core/hle/service/hid/controllers/types/mouse_types.h b/src/core/hle/service/hid/controllers/types/mouse_types.h new file mode 100644 index 000000000..8bd6e167c --- /dev/null +++ b/src/core/hle/service/hid/controllers/types/mouse_types.h | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "common/common_types.h" | ||
| 7 | |||
| 8 | namespace Service::HID {} // namespace Service::HID | ||
diff --git a/src/core/hle/service/hid/controllers/types/npad_types.h b/src/core/hle/service/hid/controllers/types/npad_types.h new file mode 100644 index 000000000..a5ce2562b --- /dev/null +++ b/src/core/hle/service/hid/controllers/types/npad_types.h | |||
| @@ -0,0 +1,254 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "common/bit_field.h" | ||
| 7 | #include "common/common_funcs.h" | ||
| 8 | #include "common/common_types.h" | ||
| 9 | #include "core/hid/hid_types.h" | ||
| 10 | |||
| 11 | namespace Service::HID { | ||
| 12 | static constexpr std::size_t NpadCount = 10; | ||
| 13 | |||
| 14 | // This is nn::hid::NpadJoyHoldType | ||
| 15 | enum class NpadJoyHoldType : u64 { | ||
| 16 | Vertical = 0, | ||
| 17 | Horizontal = 1, | ||
| 18 | }; | ||
| 19 | |||
| 20 | // This is nn::hid::NpadJoyAssignmentMode | ||
| 21 | enum class NpadJoyAssignmentMode : u32 { | ||
| 22 | Dual = 0, | ||
| 23 | Single = 1, | ||
| 24 | }; | ||
| 25 | |||
| 26 | // This is nn::hid::NpadJoyDeviceType | ||
| 27 | enum class NpadJoyDeviceType : s64 { | ||
| 28 | Left = 0, | ||
| 29 | Right = 1, | ||
| 30 | }; | ||
| 31 | |||
| 32 | // This is nn::hid::NpadHandheldActivationMode | ||
| 33 | enum class NpadHandheldActivationMode : u64 { | ||
| 34 | Dual = 0, | ||
| 35 | Single = 1, | ||
| 36 | None = 2, | ||
| 37 | MaxActivationMode = 3, | ||
| 38 | }; | ||
| 39 | |||
| 40 | // This is nn::hid::system::AppletFooterUiAttributesSet | ||
| 41 | struct AppletFooterUiAttributes { | ||
| 42 | INSERT_PADDING_BYTES(0x4); | ||
| 43 | }; | ||
| 44 | |||
| 45 | // This is nn::hid::system::AppletFooterUiType | ||
| 46 | enum class AppletFooterUiType : u8 { | ||
| 47 | None = 0, | ||
| 48 | HandheldNone = 1, | ||
| 49 | HandheldJoyConLeftOnly = 2, | ||
| 50 | HandheldJoyConRightOnly = 3, | ||
| 51 | HandheldJoyConLeftJoyConRight = 4, | ||
| 52 | JoyDual = 5, | ||
| 53 | JoyDualLeftOnly = 6, | ||
| 54 | JoyDualRightOnly = 7, | ||
| 55 | JoyLeftHorizontal = 8, | ||
| 56 | JoyLeftVertical = 9, | ||
| 57 | JoyRightHorizontal = 10, | ||
| 58 | JoyRightVertical = 11, | ||
| 59 | SwitchProController = 12, | ||
| 60 | CompatibleProController = 13, | ||
| 61 | CompatibleJoyCon = 14, | ||
| 62 | LarkHvc1 = 15, | ||
| 63 | LarkHvc2 = 16, | ||
| 64 | LarkNesLeft = 17, | ||
| 65 | LarkNesRight = 18, | ||
| 66 | Lucia = 19, | ||
| 67 | Verification = 20, | ||
| 68 | Lagon = 21, | ||
| 69 | }; | ||
| 70 | |||
| 71 | using AppletFooterUiVariant = u8; | ||
| 72 | |||
| 73 | // This is "nn::hid::system::AppletDetailedUiType". | ||
| 74 | struct AppletDetailedUiType { | ||
| 75 | AppletFooterUiVariant ui_variant; | ||
| 76 | INSERT_PADDING_BYTES(0x2); | ||
| 77 | AppletFooterUiType footer; | ||
| 78 | }; | ||
| 79 | static_assert(sizeof(AppletDetailedUiType) == 0x4, "AppletDetailedUiType is an invalid size"); | ||
| 80 | // This is nn::hid::NpadCommunicationMode | ||
| 81 | enum class NpadCommunicationMode : u64 { | ||
| 82 | Mode_5ms = 0, | ||
| 83 | Mode_10ms = 1, | ||
| 84 | Mode_15ms = 2, | ||
| 85 | Default = 3, | ||
| 86 | }; | ||
| 87 | |||
| 88 | enum class NpadRevision : u32 { | ||
| 89 | Revision0 = 0, | ||
| 90 | Revision1 = 1, | ||
| 91 | Revision2 = 2, | ||
| 92 | Revision3 = 3, | ||
| 93 | }; | ||
| 94 | |||
| 95 | // This is nn::hid::detail::ColorAttribute | ||
| 96 | enum class ColorAttribute : u32 { | ||
| 97 | Ok = 0, | ||
| 98 | ReadError = 1, | ||
| 99 | NoController = 2, | ||
| 100 | }; | ||
| 101 | static_assert(sizeof(ColorAttribute) == 4, "ColorAttribute is an invalid size"); | ||
| 102 | |||
| 103 | // This is nn::hid::detail::NpadFullKeyColorState | ||
| 104 | struct NpadFullKeyColorState { | ||
| 105 | ColorAttribute attribute{ColorAttribute::NoController}; | ||
| 106 | Core::HID::NpadControllerColor fullkey{}; | ||
| 107 | }; | ||
| 108 | static_assert(sizeof(NpadFullKeyColorState) == 0xC, "NpadFullKeyColorState is an invalid size"); | ||
| 109 | |||
| 110 | // This is nn::hid::detail::NpadJoyColorState | ||
| 111 | struct NpadJoyColorState { | ||
| 112 | ColorAttribute attribute{ColorAttribute::NoController}; | ||
| 113 | Core::HID::NpadControllerColor left{}; | ||
| 114 | Core::HID::NpadControllerColor right{}; | ||
| 115 | }; | ||
| 116 | static_assert(sizeof(NpadJoyColorState) == 0x14, "NpadJoyColorState is an invalid size"); | ||
| 117 | |||
| 118 | // This is nn::hid::NpadAttribute | ||
| 119 | struct NpadAttribute { | ||
| 120 | union { | ||
| 121 | u32 raw{}; | ||
| 122 | BitField<0, 1, u32> is_connected; | ||
| 123 | BitField<1, 1, u32> is_wired; | ||
| 124 | BitField<2, 1, u32> is_left_connected; | ||
| 125 | BitField<3, 1, u32> is_left_wired; | ||
| 126 | BitField<4, 1, u32> is_right_connected; | ||
| 127 | BitField<5, 1, u32> is_right_wired; | ||
| 128 | }; | ||
| 129 | }; | ||
| 130 | static_assert(sizeof(NpadAttribute) == 4, "NpadAttribute is an invalid size"); | ||
| 131 | |||
| 132 | // This is nn::hid::NpadFullKeyState | ||
| 133 | // This is nn::hid::NpadHandheldState | ||
| 134 | // This is nn::hid::NpadJoyDualState | ||
| 135 | // This is nn::hid::NpadJoyLeftState | ||
| 136 | // This is nn::hid::NpadJoyRightState | ||
| 137 | // This is nn::hid::NpadPalmaState | ||
| 138 | // This is nn::hid::NpadSystemExtState | ||
| 139 | struct NPadGenericState { | ||
| 140 | s64_le sampling_number{}; | ||
| 141 | Core::HID::NpadButtonState npad_buttons{}; | ||
| 142 | Core::HID::AnalogStickState l_stick{}; | ||
| 143 | Core::HID::AnalogStickState r_stick{}; | ||
| 144 | NpadAttribute connection_status{}; | ||
| 145 | INSERT_PADDING_BYTES(4); // Reserved | ||
| 146 | }; | ||
| 147 | static_assert(sizeof(NPadGenericState) == 0x28, "NPadGenericState is an invalid size"); | ||
| 148 | |||
| 149 | // This is nn::hid::server::NpadGcTriggerState | ||
| 150 | struct NpadGcTriggerState { | ||
| 151 | s64 sampling_number{}; | ||
| 152 | s32 l_analog{}; | ||
| 153 | s32 r_analog{}; | ||
| 154 | }; | ||
| 155 | static_assert(sizeof(NpadGcTriggerState) == 0x10, "NpadGcTriggerState is an invalid size"); | ||
| 156 | |||
| 157 | // This is nn::hid::NpadSystemProperties | ||
| 158 | struct NPadSystemProperties { | ||
| 159 | union { | ||
| 160 | s64 raw{}; | ||
| 161 | BitField<0, 1, s64> is_charging_joy_dual; | ||
| 162 | BitField<1, 1, s64> is_charging_joy_left; | ||
| 163 | BitField<2, 1, s64> is_charging_joy_right; | ||
| 164 | BitField<3, 1, s64> is_powered_joy_dual; | ||
| 165 | BitField<4, 1, s64> is_powered_joy_left; | ||
| 166 | BitField<5, 1, s64> is_powered_joy_right; | ||
| 167 | BitField<9, 1, s64> is_system_unsupported_button; | ||
| 168 | BitField<10, 1, s64> is_system_ext_unsupported_button; | ||
| 169 | BitField<11, 1, s64> is_vertical; | ||
| 170 | BitField<12, 1, s64> is_horizontal; | ||
| 171 | BitField<13, 1, s64> use_plus; | ||
| 172 | BitField<14, 1, s64> use_minus; | ||
| 173 | BitField<15, 1, s64> use_directional_buttons; | ||
| 174 | }; | ||
| 175 | }; | ||
| 176 | static_assert(sizeof(NPadSystemProperties) == 0x8, "NPadSystemProperties is an invalid size"); | ||
| 177 | |||
| 178 | // This is nn::hid::NpadSystemButtonProperties | ||
| 179 | struct NpadSystemButtonProperties { | ||
| 180 | union { | ||
| 181 | s32 raw{}; | ||
| 182 | BitField<0, 1, s32> is_home_button_protection_enabled; | ||
| 183 | }; | ||
| 184 | }; | ||
| 185 | static_assert(sizeof(NpadSystemButtonProperties) == 0x4, "NPadButtonProperties is an invalid size"); | ||
| 186 | |||
| 187 | // This is nn::hid::system::DeviceType | ||
| 188 | struct DeviceType { | ||
| 189 | union { | ||
| 190 | u32 raw{}; | ||
| 191 | BitField<0, 1, s32> fullkey; | ||
| 192 | BitField<1, 1, s32> debug_pad; | ||
| 193 | BitField<2, 1, s32> handheld_left; | ||
| 194 | BitField<3, 1, s32> handheld_right; | ||
| 195 | BitField<4, 1, s32> joycon_left; | ||
| 196 | BitField<5, 1, s32> joycon_right; | ||
| 197 | BitField<6, 1, s32> palma; | ||
| 198 | BitField<7, 1, s32> lark_hvc_left; | ||
| 199 | BitField<8, 1, s32> lark_hvc_right; | ||
| 200 | BitField<9, 1, s32> lark_nes_left; | ||
| 201 | BitField<10, 1, s32> lark_nes_right; | ||
| 202 | BitField<11, 1, s32> handheld_lark_hvc_left; | ||
| 203 | BitField<12, 1, s32> handheld_lark_hvc_right; | ||
| 204 | BitField<13, 1, s32> handheld_lark_nes_left; | ||
| 205 | BitField<14, 1, s32> handheld_lark_nes_right; | ||
| 206 | BitField<15, 1, s32> lucia; | ||
| 207 | BitField<16, 1, s32> lagon; | ||
| 208 | BitField<17, 1, s32> lager; | ||
| 209 | BitField<31, 1, s32> system; | ||
| 210 | }; | ||
| 211 | }; | ||
| 212 | |||
| 213 | // This is nn::hid::detail::NfcXcdDeviceHandleStateImpl | ||
| 214 | struct NfcXcdDeviceHandleStateImpl { | ||
| 215 | u64 handle{}; | ||
| 216 | bool is_available{}; | ||
| 217 | bool is_activated{}; | ||
| 218 | INSERT_PADDING_BYTES(0x6); // Reserved | ||
| 219 | u64 sampling_number{}; | ||
| 220 | }; | ||
| 221 | static_assert(sizeof(NfcXcdDeviceHandleStateImpl) == 0x18, | ||
| 222 | "NfcXcdDeviceHandleStateImpl is an invalid size"); | ||
| 223 | |||
| 224 | // This is nn::hid::NpadLarkType | ||
| 225 | enum class NpadLarkType : u32 { | ||
| 226 | Invalid, | ||
| 227 | H1, | ||
| 228 | H2, | ||
| 229 | NL, | ||
| 230 | NR, | ||
| 231 | }; | ||
| 232 | |||
| 233 | // This is nn::hid::NpadLuciaType | ||
| 234 | enum class NpadLuciaType : u32 { | ||
| 235 | Invalid, | ||
| 236 | J, | ||
| 237 | E, | ||
| 238 | U, | ||
| 239 | }; | ||
| 240 | |||
| 241 | // This is nn::hid::NpadLagonType | ||
| 242 | enum class NpadLagonType : u32 { | ||
| 243 | Invalid, | ||
| 244 | }; | ||
| 245 | |||
| 246 | // This is nn::hid::NpadLagerType | ||
| 247 | enum class NpadLagerType : u32 { | ||
| 248 | Invalid, | ||
| 249 | J, | ||
| 250 | E, | ||
| 251 | U, | ||
| 252 | }; | ||
| 253 | |||
| 254 | } // namespace Service::HID | ||
diff --git a/src/core/hle/service/hid/controllers/types/touch_types.h b/src/core/hle/service/hid/controllers/types/touch_types.h new file mode 100644 index 000000000..efeaa796d --- /dev/null +++ b/src/core/hle/service/hid/controllers/types/touch_types.h | |||
| @@ -0,0 +1,90 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <array> | ||
| 7 | |||
| 8 | #include <array> | ||
| 9 | #include "common/bit_field.h" | ||
| 10 | #include "common/common_funcs.h" | ||
| 11 | #include "common/common_types.h" | ||
| 12 | #include "common/point.h" | ||
| 13 | #include "core/hid/hid_types.h" | ||
| 14 | |||
| 15 | namespace Service::HID { | ||
| 16 | static constexpr std::size_t MAX_FINGERS = 16; | ||
| 17 | static constexpr size_t MAX_POINTS = 4; | ||
| 18 | |||
| 19 | // This is nn::hid::GestureType | ||
| 20 | enum class GestureType : u32 { | ||
| 21 | Idle, // Nothing touching the screen | ||
| 22 | Complete, // Set at the end of a touch event | ||
| 23 | Cancel, // Set when the number of fingers change | ||
| 24 | Touch, // A finger just touched the screen | ||
| 25 | Press, // Set if last type is touch and the finger hasn't moved | ||
| 26 | Tap, // Fast press then release | ||
| 27 | Pan, // All points moving together across the screen | ||
| 28 | Swipe, // Fast press movement and release of a single point | ||
| 29 | Pinch, // All points moving away/closer to the midpoint | ||
| 30 | Rotate, // All points rotating from the midpoint | ||
| 31 | }; | ||
| 32 | |||
| 33 | // This is nn::hid::GestureDirection | ||
| 34 | enum class GestureDirection : u32 { | ||
| 35 | None, | ||
| 36 | Left, | ||
| 37 | Up, | ||
| 38 | Right, | ||
| 39 | Down, | ||
| 40 | }; | ||
| 41 | |||
| 42 | // This is nn::hid::GestureAttribute | ||
| 43 | struct GestureAttribute { | ||
| 44 | union { | ||
| 45 | u32 raw{}; | ||
| 46 | |||
| 47 | BitField<4, 1, u32> is_new_touch; | ||
| 48 | BitField<8, 1, u32> is_double_tap; | ||
| 49 | }; | ||
| 50 | }; | ||
| 51 | static_assert(sizeof(GestureAttribute) == 4, "GestureAttribute is an invalid size"); | ||
| 52 | |||
| 53 | // This is nn::hid::GestureState | ||
| 54 | struct GestureState { | ||
| 55 | s64 sampling_number{}; | ||
| 56 | s64 detection_count{}; | ||
| 57 | GestureType type{GestureType::Idle}; | ||
| 58 | GestureDirection direction{GestureDirection::None}; | ||
| 59 | Common::Point<s32> pos{}; | ||
| 60 | Common::Point<s32> delta{}; | ||
| 61 | f32 vel_x{}; | ||
| 62 | f32 vel_y{}; | ||
| 63 | GestureAttribute attributes{}; | ||
| 64 | f32 scale{}; | ||
| 65 | f32 rotation_angle{}; | ||
| 66 | s32 point_count{}; | ||
| 67 | std::array<Common::Point<s32>, 4> points{}; | ||
| 68 | }; | ||
| 69 | static_assert(sizeof(GestureState) == 0x60, "GestureState is an invalid size"); | ||
| 70 | |||
| 71 | struct GestureProperties { | ||
| 72 | std::array<Common::Point<s32>, MAX_POINTS> points{}; | ||
| 73 | std::size_t active_points{}; | ||
| 74 | Common::Point<s32> mid_point{}; | ||
| 75 | s64 detection_count{}; | ||
| 76 | u64 delta_time{}; | ||
| 77 | f32 average_distance{}; | ||
| 78 | f32 angle{}; | ||
| 79 | }; | ||
| 80 | |||
| 81 | // This is nn::hid::TouchScreenState | ||
| 82 | struct TouchScreenState { | ||
| 83 | s64 sampling_number{}; | ||
| 84 | s32 entry_count{}; | ||
| 85 | INSERT_PADDING_BYTES(4); // Reserved | ||
| 86 | std::array<Core::HID::TouchState, MAX_FINGERS> states{}; | ||
| 87 | }; | ||
| 88 | static_assert(sizeof(TouchScreenState) == 0x290, "TouchScreenState is an invalid size"); | ||
| 89 | |||
| 90 | } // namespace Service::HID | ||
diff --git a/src/core/hle/service/hid/controllers/xpad.cpp b/src/core/hle/service/hid/controllers/xpad.cpp deleted file mode 100644 index 0aaed1fa7..000000000 --- a/src/core/hle/service/hid/controllers/xpad.cpp +++ /dev/null | |||
| @@ -1,39 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include <cstring> | ||
| 5 | #include "common/common_types.h" | ||
| 6 | #include "core/core_timing.h" | ||
| 7 | #include "core/hid/hid_core.h" | ||
| 8 | #include "core/hle/service/hid/controllers/xpad.h" | ||
| 9 | |||
| 10 | namespace Service::HID { | ||
| 11 | constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3C00; | ||
| 12 | |||
| 13 | XPad::XPad(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_) : ControllerBase{hid_core_} { | ||
| 14 | static_assert(SHARED_MEMORY_OFFSET + sizeof(XpadSharedMemory) < shared_memory_size, | ||
| 15 | "XpadSharedMemory is bigger than the shared memory"); | ||
| 16 | shared_memory = std::construct_at( | ||
| 17 | reinterpret_cast<XpadSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET)); | ||
| 18 | } | ||
| 19 | XPad::~XPad() = default; | ||
| 20 | |||
| 21 | void XPad::OnInit() {} | ||
| 22 | |||
| 23 | void XPad::OnRelease() {} | ||
| 24 | |||
| 25 | void XPad::OnUpdate(const Core::Timing::CoreTiming& core_timing) { | ||
| 26 | if (!IsControllerActivated()) { | ||
| 27 | shared_memory->basic_xpad_lifo.buffer_count = 0; | ||
| 28 | shared_memory->basic_xpad_lifo.buffer_tail = 0; | ||
| 29 | return; | ||
| 30 | } | ||
| 31 | |||
| 32 | const auto& last_entry = shared_memory->basic_xpad_lifo.ReadCurrentEntry().state; | ||
| 33 | next_state.sampling_number = last_entry.sampling_number + 1; | ||
| 34 | // TODO(ogniK): Update xpad states | ||
| 35 | |||
| 36 | shared_memory->basic_xpad_lifo.WriteNextEntry(next_state); | ||
| 37 | } | ||
| 38 | |||
| 39 | } // namespace Service::HID | ||
diff --git a/src/core/hle/service/hid/controllers/xpad.h b/src/core/hle/service/hid/controllers/xpad.h deleted file mode 100644 index 9e63a317a..000000000 --- a/src/core/hle/service/hid/controllers/xpad.h +++ /dev/null | |||
| @@ -1,112 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "common/bit_field.h" | ||
| 7 | #include "common/common_types.h" | ||
| 8 | #include "core/hid/hid_types.h" | ||
| 9 | #include "core/hle/service/hid/controllers/controller_base.h" | ||
| 10 | #include "core/hle/service/hid/ring_lifo.h" | ||
| 11 | |||
| 12 | namespace Service::HID { | ||
| 13 | class XPad final : public ControllerBase { | ||
| 14 | public: | ||
| 15 | explicit XPad(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_); | ||
| 16 | ~XPad() override; | ||
| 17 | |||
| 18 | // Called when the controller is initialized | ||
| 19 | void OnInit() override; | ||
| 20 | |||
| 21 | // When the controller is released | ||
| 22 | void OnRelease() override; | ||
| 23 | |||
| 24 | // When the controller is requesting an update for the shared memory | ||
| 25 | void OnUpdate(const Core::Timing::CoreTiming& core_timing) override; | ||
| 26 | |||
| 27 | private: | ||
| 28 | // This is nn::hid::BasicXpadAttributeSet | ||
| 29 | struct BasicXpadAttributeSet { | ||
| 30 | union { | ||
| 31 | u32 raw{}; | ||
| 32 | BitField<0, 1, u32> is_connected; | ||
| 33 | BitField<1, 1, u32> is_wired; | ||
| 34 | BitField<2, 1, u32> is_left_connected; | ||
| 35 | BitField<3, 1, u32> is_left_wired; | ||
| 36 | BitField<4, 1, u32> is_right_connected; | ||
| 37 | BitField<5, 1, u32> is_right_wired; | ||
| 38 | }; | ||
| 39 | }; | ||
| 40 | static_assert(sizeof(BasicXpadAttributeSet) == 4, "BasicXpadAttributeSet is an invalid size"); | ||
| 41 | |||
| 42 | // This is nn::hid::BasicXpadButtonSet | ||
| 43 | struct BasicXpadButtonSet { | ||
| 44 | union { | ||
| 45 | u32 raw{}; | ||
| 46 | // Button states | ||
| 47 | BitField<0, 1, u32> a; | ||
| 48 | BitField<1, 1, u32> b; | ||
| 49 | BitField<2, 1, u32> x; | ||
| 50 | BitField<3, 1, u32> y; | ||
| 51 | BitField<4, 1, u32> l_stick; | ||
| 52 | BitField<5, 1, u32> r_stick; | ||
| 53 | BitField<6, 1, u32> l; | ||
| 54 | BitField<7, 1, u32> r; | ||
| 55 | BitField<8, 1, u32> zl; | ||
| 56 | BitField<9, 1, u32> zr; | ||
| 57 | BitField<10, 1, u32> plus; | ||
| 58 | BitField<11, 1, u32> minus; | ||
| 59 | |||
| 60 | // D-Pad | ||
| 61 | BitField<12, 1, u32> d_left; | ||
| 62 | BitField<13, 1, u32> d_up; | ||
| 63 | BitField<14, 1, u32> d_right; | ||
| 64 | BitField<15, 1, u32> d_down; | ||
| 65 | |||
| 66 | // Left JoyStick | ||
| 67 | BitField<16, 1, u32> l_stick_left; | ||
| 68 | BitField<17, 1, u32> l_stick_up; | ||
| 69 | BitField<18, 1, u32> l_stick_right; | ||
| 70 | BitField<19, 1, u32> l_stick_down; | ||
| 71 | |||
| 72 | // Right JoyStick | ||
| 73 | BitField<20, 1, u32> r_stick_left; | ||
| 74 | BitField<21, 1, u32> r_stick_up; | ||
| 75 | BitField<22, 1, u32> r_stick_right; | ||
| 76 | BitField<23, 1, u32> r_stick_down; | ||
| 77 | |||
| 78 | // Not always active? | ||
| 79 | BitField<24, 1, u32> left_sl; | ||
| 80 | BitField<25, 1, u32> left_sr; | ||
| 81 | |||
| 82 | BitField<26, 1, u32> right_sl; | ||
| 83 | BitField<27, 1, u32> right_sr; | ||
| 84 | |||
| 85 | BitField<28, 1, u32> palma; | ||
| 86 | BitField<30, 1, u32> handheld_left_b; | ||
| 87 | }; | ||
| 88 | }; | ||
| 89 | static_assert(sizeof(BasicXpadButtonSet) == 4, "BasicXpadButtonSet is an invalid size"); | ||
| 90 | |||
| 91 | // This is nn::hid::detail::BasicXpadState | ||
| 92 | struct BasicXpadState { | ||
| 93 | s64 sampling_number{}; | ||
| 94 | BasicXpadAttributeSet attributes{}; | ||
| 95 | BasicXpadButtonSet pad_states{}; | ||
| 96 | Core::HID::AnalogStickState l_stick{}; | ||
| 97 | Core::HID::AnalogStickState r_stick{}; | ||
| 98 | }; | ||
| 99 | static_assert(sizeof(BasicXpadState) == 0x20, "BasicXpadState is an invalid size"); | ||
| 100 | |||
| 101 | struct XpadSharedMemory { | ||
| 102 | // This is nn::hid::detail::BasicXpadLifo | ||
| 103 | Lifo<BasicXpadState, hid_entry_count> basic_xpad_lifo{}; | ||
| 104 | static_assert(sizeof(basic_xpad_lifo) == 0x2C8, "basic_xpad_lifo is an invalid size"); | ||
| 105 | INSERT_PADDING_WORDS(0x4E); | ||
| 106 | }; | ||
| 107 | static_assert(sizeof(XpadSharedMemory) == 0x400, "XpadSharedMemory is an invalid size"); | ||
| 108 | |||
| 109 | BasicXpadState next_state{}; | ||
| 110 | XpadSharedMemory* shared_memory = nullptr; | ||
| 111 | }; | ||
| 112 | } // namespace Service::HID | ||
diff --git a/src/core/hle/service/hid/errors.h b/src/core/hle/service/hid/errors.h index f00cb831f..6dc976fe1 100644 --- a/src/core/hle/service/hid/errors.h +++ b/src/core/hle/service/hid/errors.h | |||
| @@ -20,6 +20,9 @@ constexpr Result InvalidNpadId{ErrorModule::HID, 709}; | |||
| 20 | constexpr Result NpadNotConnected{ErrorModule::HID, 710}; | 20 | constexpr Result NpadNotConnected{ErrorModule::HID, 710}; |
| 21 | constexpr Result InvalidArraySize{ErrorModule::HID, 715}; | 21 | constexpr Result InvalidArraySize{ErrorModule::HID, 715}; |
| 22 | 22 | ||
| 23 | constexpr Result ResultAppletResourceOverflow{ErrorModule::HID, 1041}; | ||
| 24 | constexpr Result ResultAppletResourceNotInitialized{ErrorModule::HID, 1042}; | ||
| 25 | constexpr Result ResultSharedMemoryNotInitialized{ErrorModule::HID, 1043}; | ||
| 23 | constexpr Result ResultAruidNoAvailableEntries{ErrorModule::HID, 1044}; | 26 | constexpr Result ResultAruidNoAvailableEntries{ErrorModule::HID, 1044}; |
| 24 | constexpr Result ResultAruidAlreadyRegistered{ErrorModule::HID, 1046}; | 27 | constexpr Result ResultAruidAlreadyRegistered{ErrorModule::HID, 1046}; |
| 25 | constexpr Result ResultAruidNotRegistered{ErrorModule::HID, 1047}; | 28 | constexpr Result ResultAruidNotRegistered{ErrorModule::HID, 1047}; |
diff --git a/src/core/hle/service/hid/hid_server.cpp b/src/core/hle/service/hid/hid_server.cpp index e0f4051aa..de24b0401 100644 --- a/src/core/hle/service/hid/hid_server.cpp +++ b/src/core/hle/service/hid/hid_server.cpp | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | #include "core/hle/service/hid/controllers/seven_six_axis.h" | 28 | #include "core/hle/service/hid/controllers/seven_six_axis.h" |
| 29 | #include "core/hle/service/hid/controllers/six_axis.h" | 29 | #include "core/hle/service/hid/controllers/six_axis.h" |
| 30 | #include "core/hle/service/hid/controllers/touchscreen.h" | 30 | #include "core/hle/service/hid/controllers/touchscreen.h" |
| 31 | #include "core/hle/service/hid/controllers/types/npad_types.h" | ||
| 31 | 32 | ||
| 32 | namespace Service::HID { | 33 | namespace Service::HID { |
| 33 | 34 | ||
| @@ -222,16 +223,14 @@ void IHidServer::CreateAppletResource(HLERequestContext& ctx) { | |||
| 222 | IPC::RequestParser rp{ctx}; | 223 | IPC::RequestParser rp{ctx}; |
| 223 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 224 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
| 224 | 225 | ||
| 225 | LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | ||
| 226 | |||
| 227 | Result result = GetResourceManager()->CreateAppletResource(applet_resource_user_id); | 226 | Result result = GetResourceManager()->CreateAppletResource(applet_resource_user_id); |
| 228 | if (result.IsSuccess()) { | 227 | |
| 229 | result = GetResourceManager()->GetNpad()->Activate(applet_resource_user_id); | 228 | LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}, result=0x{:X}", |
| 230 | } | 229 | applet_resource_user_id, result.raw); |
| 231 | 230 | ||
| 232 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 231 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 233 | rb.Push(result); | 232 | rb.Push(result); |
| 234 | rb.PushIpcInterface<IAppletResource>(system, resource_manager); | 233 | rb.PushIpcInterface<IAppletResource>(system, resource_manager, applet_resource_user_id); |
| 235 | } | 234 | } |
| 236 | 235 | ||
| 237 | void IHidServer::ActivateDebugPad(HLERequestContext& ctx) { | 236 | void IHidServer::ActivateDebugPad(HLERequestContext& ctx) { |
| @@ -1101,7 +1100,7 @@ void IHidServer::GetPlayerLedPattern(HLERequestContext& ctx) { | |||
| 1101 | void IHidServer::ActivateNpadWithRevision(HLERequestContext& ctx) { | 1100 | void IHidServer::ActivateNpadWithRevision(HLERequestContext& ctx) { |
| 1102 | IPC::RequestParser rp{ctx}; | 1101 | IPC::RequestParser rp{ctx}; |
| 1103 | struct Parameters { | 1102 | struct Parameters { |
| 1104 | NPad::NpadRevision revision; | 1103 | NpadRevision revision; |
| 1105 | INSERT_PADDING_WORDS_NOINIT(1); | 1104 | INSERT_PADDING_WORDS_NOINIT(1); |
| 1106 | u64 applet_resource_user_id; | 1105 | u64 applet_resource_user_id; |
| 1107 | }; | 1106 | }; |
| @@ -1124,7 +1123,7 @@ void IHidServer::ActivateNpadWithRevision(HLERequestContext& ctx) { | |||
| 1124 | void IHidServer::SetNpadJoyHoldType(HLERequestContext& ctx) { | 1123 | void IHidServer::SetNpadJoyHoldType(HLERequestContext& ctx) { |
| 1125 | IPC::RequestParser rp{ctx}; | 1124 | IPC::RequestParser rp{ctx}; |
| 1126 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 1125 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
| 1127 | const auto hold_type{rp.PopEnum<NPad::NpadJoyHoldType>()}; | 1126 | const auto hold_type{rp.PopEnum<NpadJoyHoldType>()}; |
| 1128 | 1127 | ||
| 1129 | GetResourceManager()->GetNpad()->SetHoldType(hold_type); | 1128 | GetResourceManager()->GetNpad()->SetHoldType(hold_type); |
| 1130 | 1129 | ||
| @@ -1159,8 +1158,8 @@ void IHidServer::SetNpadJoyAssignmentModeSingleByDefault(HLERequestContext& ctx) | |||
| 1159 | 1158 | ||
| 1160 | Core::HID::NpadIdType new_npad_id{}; | 1159 | Core::HID::NpadIdType new_npad_id{}; |
| 1161 | auto controller = GetResourceManager()->GetNpad(); | 1160 | auto controller = GetResourceManager()->GetNpad(); |
| 1162 | controller->SetNpadMode(new_npad_id, parameters.npad_id, NPad::NpadJoyDeviceType::Left, | 1161 | controller->SetNpadMode(new_npad_id, parameters.npad_id, NpadJoyDeviceType::Left, |
| 1163 | NPad::NpadJoyAssignmentMode::Single); | 1162 | NpadJoyAssignmentMode::Single); |
| 1164 | 1163 | ||
| 1165 | LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id, | 1164 | LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id, |
| 1166 | parameters.applet_resource_user_id); | 1165 | parameters.applet_resource_user_id); |
| @@ -1175,7 +1174,7 @@ void IHidServer::SetNpadJoyAssignmentModeSingle(HLERequestContext& ctx) { | |||
| 1175 | Core::HID::NpadIdType npad_id; | 1174 | Core::HID::NpadIdType npad_id; |
| 1176 | INSERT_PADDING_WORDS_NOINIT(1); | 1175 | INSERT_PADDING_WORDS_NOINIT(1); |
| 1177 | u64 applet_resource_user_id; | 1176 | u64 applet_resource_user_id; |
| 1178 | NPad::NpadJoyDeviceType npad_joy_device_type; | 1177 | NpadJoyDeviceType npad_joy_device_type; |
| 1179 | }; | 1178 | }; |
| 1180 | static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size."); | 1179 | static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size."); |
| 1181 | 1180 | ||
| @@ -1184,7 +1183,7 @@ void IHidServer::SetNpadJoyAssignmentModeSingle(HLERequestContext& ctx) { | |||
| 1184 | Core::HID::NpadIdType new_npad_id{}; | 1183 | Core::HID::NpadIdType new_npad_id{}; |
| 1185 | auto controller = GetResourceManager()->GetNpad(); | 1184 | auto controller = GetResourceManager()->GetNpad(); |
| 1186 | controller->SetNpadMode(new_npad_id, parameters.npad_id, parameters.npad_joy_device_type, | 1185 | controller->SetNpadMode(new_npad_id, parameters.npad_id, parameters.npad_joy_device_type, |
| 1187 | NPad::NpadJoyAssignmentMode::Single); | 1186 | NpadJoyAssignmentMode::Single); |
| 1188 | 1187 | ||
| 1189 | LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}, npad_joy_device_type={}", | 1188 | LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}, npad_joy_device_type={}", |
| 1190 | parameters.npad_id, parameters.applet_resource_user_id, | 1189 | parameters.npad_id, parameters.applet_resource_user_id, |
| @@ -1207,7 +1206,7 @@ void IHidServer::SetNpadJoyAssignmentModeDual(HLERequestContext& ctx) { | |||
| 1207 | 1206 | ||
| 1208 | Core::HID::NpadIdType new_npad_id{}; | 1207 | Core::HID::NpadIdType new_npad_id{}; |
| 1209 | auto controller = GetResourceManager()->GetNpad(); | 1208 | auto controller = GetResourceManager()->GetNpad(); |
| 1210 | controller->SetNpadMode(new_npad_id, parameters.npad_id, {}, NPad::NpadJoyAssignmentMode::Dual); | 1209 | controller->SetNpadMode(new_npad_id, parameters.npad_id, {}, NpadJoyAssignmentMode::Dual); |
| 1211 | 1210 | ||
| 1212 | LOG_DEBUG(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id, | 1211 | LOG_DEBUG(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id, |
| 1213 | parameters.applet_resource_user_id); // Spams a lot when controller applet is open | 1212 | parameters.applet_resource_user_id); // Spams a lot when controller applet is open |
| @@ -1259,7 +1258,7 @@ void IHidServer::StopLrAssignmentMode(HLERequestContext& ctx) { | |||
| 1259 | void IHidServer::SetNpadHandheldActivationMode(HLERequestContext& ctx) { | 1258 | void IHidServer::SetNpadHandheldActivationMode(HLERequestContext& ctx) { |
| 1260 | IPC::RequestParser rp{ctx}; | 1259 | IPC::RequestParser rp{ctx}; |
| 1261 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 1260 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
| 1262 | const auto activation_mode{rp.PopEnum<NPad::NpadHandheldActivationMode>()}; | 1261 | const auto activation_mode{rp.PopEnum<NpadHandheldActivationMode>()}; |
| 1263 | 1262 | ||
| 1264 | GetResourceManager()->GetNpad()->SetNpadHandheldActivationMode(activation_mode); | 1263 | GetResourceManager()->GetNpad()->SetNpadHandheldActivationMode(activation_mode); |
| 1265 | 1264 | ||
| @@ -1351,7 +1350,7 @@ void IHidServer::SetNpadJoyAssignmentModeSingleWithDestination(HLERequestContext | |||
| 1351 | Core::HID::NpadIdType npad_id; | 1350 | Core::HID::NpadIdType npad_id; |
| 1352 | INSERT_PADDING_WORDS_NOINIT(1); | 1351 | INSERT_PADDING_WORDS_NOINIT(1); |
| 1353 | u64 applet_resource_user_id; | 1352 | u64 applet_resource_user_id; |
| 1354 | NPad::NpadJoyDeviceType npad_joy_device_type; | 1353 | NpadJoyDeviceType npad_joy_device_type; |
| 1355 | }; | 1354 | }; |
| 1356 | static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size."); | 1355 | static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size."); |
| 1357 | 1356 | ||
| @@ -1361,7 +1360,7 @@ void IHidServer::SetNpadJoyAssignmentModeSingleWithDestination(HLERequestContext | |||
| 1361 | auto controller = GetResourceManager()->GetNpad(); | 1360 | auto controller = GetResourceManager()->GetNpad(); |
| 1362 | const auto is_reassigned = | 1361 | const auto is_reassigned = |
| 1363 | controller->SetNpadMode(new_npad_id, parameters.npad_id, parameters.npad_joy_device_type, | 1362 | controller->SetNpadMode(new_npad_id, parameters.npad_id, parameters.npad_joy_device_type, |
| 1364 | NPad::NpadJoyAssignmentMode::Single); | 1363 | NpadJoyAssignmentMode::Single); |
| 1365 | 1364 | ||
| 1366 | LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}, npad_joy_device_type={}", | 1365 | LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}, npad_joy_device_type={}", |
| 1367 | parameters.npad_id, parameters.applet_resource_user_id, | 1366 | parameters.npad_id, parameters.applet_resource_user_id, |
| @@ -2317,7 +2316,7 @@ void IHidServer::SetDisallowedPalmaConnection(HLERequestContext& ctx) { | |||
| 2317 | void IHidServer::SetNpadCommunicationMode(HLERequestContext& ctx) { | 2316 | void IHidServer::SetNpadCommunicationMode(HLERequestContext& ctx) { |
| 2318 | IPC::RequestParser rp{ctx}; | 2317 | IPC::RequestParser rp{ctx}; |
| 2319 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 2318 | const auto applet_resource_user_id{rp.Pop<u64>()}; |
| 2320 | const auto communication_mode{rp.PopEnum<NPad::NpadCommunicationMode>()}; | 2319 | const auto communication_mode{rp.PopEnum<NpadCommunicationMode>()}; |
| 2321 | 2320 | ||
| 2322 | GetResourceManager()->GetNpad()->SetNpadCommunicationMode(communication_mode); | 2321 | GetResourceManager()->GetNpad()->SetNpadCommunicationMode(communication_mode); |
| 2323 | 2322 | ||
diff --git a/src/core/hle/service/hid/hid_system_server.cpp b/src/core/hle/service/hid/hid_system_server.cpp index 4d33456a3..5cc88c4a1 100644 --- a/src/core/hle/service/hid/hid_system_server.cpp +++ b/src/core/hle/service/hid/hid_system_server.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include "core/hle/service/hid/controllers/npad.h" | 5 | #include "core/hle/service/hid/controllers/npad.h" |
| 6 | #include "core/hle/service/hid/controllers/palma.h" | 6 | #include "core/hle/service/hid/controllers/palma.h" |
| 7 | #include "core/hle/service/hid/controllers/touchscreen.h" | 7 | #include "core/hle/service/hid/controllers/touchscreen.h" |
| 8 | #include "core/hle/service/hid/controllers/types/npad_types.h" | ||
| 8 | #include "core/hle/service/hid/errors.h" | 9 | #include "core/hle/service/hid/errors.h" |
| 9 | #include "core/hle/service/hid/hid_system_server.h" | 10 | #include "core/hle/service/hid/hid_system_server.h" |
| 10 | #include "core/hle/service/hid/resource_manager.h" | 11 | #include "core/hle/service/hid/resource_manager.h" |
| @@ -328,7 +329,7 @@ void IHidSystemServer::GetAppletDetailedUiType(HLERequestContext& ctx) { | |||
| 328 | LOG_DEBUG(Service_HID, "called, npad_id_type={}", | 329 | LOG_DEBUG(Service_HID, "called, npad_id_type={}", |
| 329 | npad_id_type); // Spams a lot when controller applet is running | 330 | npad_id_type); // Spams a lot when controller applet is running |
| 330 | 331 | ||
| 331 | const NPad::AppletDetailedUiType detailed_ui_type = | 332 | const AppletDetailedUiType detailed_ui_type = |
| 332 | GetResourceManager()->GetNpad()->GetAppletDetailedUiType(npad_id_type); | 333 | GetResourceManager()->GetNpad()->GetAppletDetailedUiType(npad_id_type); |
| 333 | 334 | ||
| 334 | IPC::ResponseBuilder rb{ctx, 3}; | 335 | IPC::ResponseBuilder rb{ctx, 3}; |
diff --git a/src/core/hle/service/hid/resource_manager.cpp b/src/core/hle/service/hid/resource_manager.cpp index 60d4ef71f..6c6cbd802 100644 --- a/src/core/hle/service/hid/resource_manager.cpp +++ b/src/core/hle/service/hid/resource_manager.cpp | |||
| @@ -18,10 +18,10 @@ | |||
| 18 | #include "core/hle/service/hid/controllers/npad.h" | 18 | #include "core/hle/service/hid/controllers/npad.h" |
| 19 | #include "core/hle/service/hid/controllers/palma.h" | 19 | #include "core/hle/service/hid/controllers/palma.h" |
| 20 | #include "core/hle/service/hid/controllers/seven_six_axis.h" | 20 | #include "core/hle/service/hid/controllers/seven_six_axis.h" |
| 21 | #include "core/hle/service/hid/controllers/shared_memory_format.h" | ||
| 21 | #include "core/hle/service/hid/controllers/six_axis.h" | 22 | #include "core/hle/service/hid/controllers/six_axis.h" |
| 22 | #include "core/hle/service/hid/controllers/stubbed.h" | 23 | #include "core/hle/service/hid/controllers/stubbed.h" |
| 23 | #include "core/hle/service/hid/controllers/touchscreen.h" | 24 | #include "core/hle/service/hid/controllers/touchscreen.h" |
| 24 | #include "core/hle/service/hid/controllers/xpad.h" | ||
| 25 | 25 | ||
| 26 | namespace Service::HID { | 26 | namespace Service::HID { |
| 27 | 27 | ||
| @@ -45,40 +45,43 @@ void ResourceManager::Initialize() { | |||
| 45 | return; | 45 | return; |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | u8* shared_memory = system.Kernel().GetHidSharedMem().GetPointer(); | 48 | system.HIDCore().ReloadInputDevices(); |
| 49 | debug_pad = std::make_shared<DebugPad>(system.HIDCore(), shared_memory); | 49 | is_initialized = true; |
| 50 | mouse = std::make_shared<Mouse>(system.HIDCore(), shared_memory); | 50 | } |
| 51 | debug_mouse = std::make_shared<DebugMouse>(system.HIDCore(), shared_memory); | 51 | |
| 52 | keyboard = std::make_shared<Keyboard>(system.HIDCore(), shared_memory); | 52 | void ResourceManager::InitializeController(u64 aruid) { |
| 53 | unique_pad = std::make_shared<UniquePad>(system.HIDCore(), shared_memory); | 53 | SharedMemoryFormat* shared_memory = nullptr; |
| 54 | npad = std::make_shared<NPad>(system.HIDCore(), shared_memory, service_context); | 54 | const auto result = applet_resource->GetSharedMemoryFormat(&shared_memory, aruid); |
| 55 | gesture = std::make_shared<Gesture>(system.HIDCore(), shared_memory); | 55 | if (result.IsError()) { |
| 56 | touch_screen = std::make_shared<TouchScreen>(system.HIDCore(), shared_memory); | 56 | return; |
| 57 | xpad = std::make_shared<XPad>(system.HIDCore(), shared_memory); | 57 | } |
| 58 | 58 | ||
| 59 | palma = std::make_shared<Palma>(system.HIDCore(), shared_memory, service_context); | 59 | debug_pad = std::make_shared<DebugPad>(system.HIDCore(), shared_memory->debug_pad); |
| 60 | mouse = std::make_shared<Mouse>(system.HIDCore(), shared_memory->mouse); | ||
| 61 | debug_mouse = std::make_shared<DebugMouse>(system.HIDCore(), shared_memory->debug_mouse); | ||
| 62 | keyboard = std::make_shared<Keyboard>(system.HIDCore(), shared_memory->keyboard); | ||
| 63 | unique_pad = std::make_shared<UniquePad>(system.HIDCore(), shared_memory->unique_pad.header); | ||
| 64 | npad = std::make_shared<NPad>(system.HIDCore(), shared_memory->npad, service_context); | ||
| 65 | gesture = std::make_shared<Gesture>(system.HIDCore(), shared_memory->gesture); | ||
| 66 | touch_screen = std::make_shared<TouchScreen>(system.HIDCore(), shared_memory->touch_screen); | ||
| 60 | 67 | ||
| 61 | home_button = std::make_shared<HomeButton>(system.HIDCore(), shared_memory); | 68 | palma = std::make_shared<Palma>(system.HIDCore(), service_context); |
| 62 | sleep_button = std::make_shared<SleepButton>(system.HIDCore(), shared_memory); | 69 | |
| 63 | capture_button = std::make_shared<CaptureButton>(system.HIDCore(), shared_memory); | 70 | home_button = std::make_shared<HomeButton>(system.HIDCore(), shared_memory->home_button.header); |
| 71 | sleep_button = | ||
| 72 | std::make_shared<SleepButton>(system.HIDCore(), shared_memory->sleep_button.header); | ||
| 73 | capture_button = | ||
| 74 | std::make_shared<CaptureButton>(system.HIDCore(), shared_memory->capture_button.header); | ||
| 75 | digitizer = std::make_shared<Digitizer>(system.HIDCore(), shared_memory->digitizer.header); | ||
| 64 | 76 | ||
| 65 | six_axis = std::make_shared<SixAxis>(system.HIDCore(), npad); | 77 | six_axis = std::make_shared<SixAxis>(system.HIDCore(), npad); |
| 66 | console_six_axis = std::make_shared<ConsoleSixAxis>(system.HIDCore(), shared_memory); | 78 | console_six_axis = std::make_shared<ConsoleSixAxis>(system.HIDCore(), shared_memory->console); |
| 67 | seven_six_axis = std::make_shared<SevenSixAxis>(system); | 79 | seven_six_axis = std::make_shared<SevenSixAxis>(system); |
| 68 | 80 | ||
| 69 | home_button->SetCommonHeaderOffset(0x4C00); | ||
| 70 | sleep_button->SetCommonHeaderOffset(0x4E00); | ||
| 71 | capture_button->SetCommonHeaderOffset(0x5000); | ||
| 72 | unique_pad->SetCommonHeaderOffset(0x5A00); | ||
| 73 | debug_mouse->SetCommonHeaderOffset(0x3DC00); | ||
| 74 | |||
| 75 | // Homebrew doesn't try to activate some controllers, so we activate them by default | 81 | // Homebrew doesn't try to activate some controllers, so we activate them by default |
| 76 | npad->Activate(); | 82 | npad->Activate(); |
| 77 | six_axis->Activate(); | 83 | six_axis->Activate(); |
| 78 | touch_screen->Activate(); | 84 | touch_screen->Activate(); |
| 79 | |||
| 80 | system.HIDCore().ReloadInputDevices(); | ||
| 81 | is_initialized = true; | ||
| 82 | } | 85 | } |
| 83 | 86 | ||
| 84 | std::shared_ptr<AppletResource> ResourceManager::GetAppletResource() const { | 87 | std::shared_ptr<AppletResource> ResourceManager::GetAppletResource() const { |
| @@ -101,6 +104,10 @@ std::shared_ptr<DebugPad> ResourceManager::GetDebugPad() const { | |||
| 101 | return debug_pad; | 104 | return debug_pad; |
| 102 | } | 105 | } |
| 103 | 106 | ||
| 107 | std::shared_ptr<Digitizer> ResourceManager::GetDigitizer() const { | ||
| 108 | return digitizer; | ||
| 109 | } | ||
| 110 | |||
| 104 | std::shared_ptr<Gesture> ResourceManager::GetGesture() const { | 111 | std::shared_ptr<Gesture> ResourceManager::GetGesture() const { |
| 105 | return gesture; | 112 | return gesture; |
| 106 | } | 113 | } |
| @@ -146,8 +153,38 @@ std::shared_ptr<UniquePad> ResourceManager::GetUniquePad() const { | |||
| 146 | } | 153 | } |
| 147 | 154 | ||
| 148 | Result ResourceManager::CreateAppletResource(u64 aruid) { | 155 | Result ResourceManager::CreateAppletResource(u64 aruid) { |
| 156 | if (aruid == 0) { | ||
| 157 | const auto result = RegisterCoreAppletResource(); | ||
| 158 | if (result.IsError()) { | ||
| 159 | return result; | ||
| 160 | } | ||
| 161 | return GetNpad()->Activate(); | ||
| 162 | } | ||
| 163 | |||
| 164 | const auto result = CreateAppletResourceImpl(aruid); | ||
| 165 | if (result.IsError()) { | ||
| 166 | return result; | ||
| 167 | } | ||
| 168 | return GetNpad()->Activate(aruid); | ||
| 169 | } | ||
| 170 | |||
| 171 | Result ResourceManager::CreateAppletResourceImpl(u64 aruid) { | ||
| 172 | std::scoped_lock lock{shared_mutex}; | ||
| 173 | const auto result = applet_resource->CreateAppletResource(aruid); | ||
| 174 | if (result.IsSuccess()) { | ||
| 175 | InitializeController(aruid); | ||
| 176 | } | ||
| 177 | return result; | ||
| 178 | } | ||
| 179 | |||
| 180 | Result ResourceManager::RegisterCoreAppletResource() { | ||
| 149 | std::scoped_lock lock{shared_mutex}; | 181 | std::scoped_lock lock{shared_mutex}; |
| 150 | return applet_resource->CreateAppletResource(aruid); | 182 | return applet_resource->RegisterCoreAppletResource(); |
| 183 | } | ||
| 184 | |||
| 185 | Result ResourceManager::UnregisterCoreAppletResource() { | ||
| 186 | std::scoped_lock lock{shared_mutex}; | ||
| 187 | return applet_resource->UnregisterCoreAppletResource(); | ||
| 151 | } | 188 | } |
| 152 | 189 | ||
| 153 | Result ResourceManager::RegisterAppletResourceUserId(u64 aruid, bool bool_value) { | 190 | Result ResourceManager::RegisterAppletResourceUserId(u64 aruid, bool bool_value) { |
| @@ -165,6 +202,11 @@ Result ResourceManager::GetSharedMemoryHandle(Kernel::KSharedMemory** out_handle | |||
| 165 | return applet_resource->GetSharedMemoryHandle(out_handle, aruid); | 202 | return applet_resource->GetSharedMemoryHandle(out_handle, aruid); |
| 166 | } | 203 | } |
| 167 | 204 | ||
| 205 | void ResourceManager::FreeAppletResourceId(u64 aruid) { | ||
| 206 | std::scoped_lock lock{shared_mutex}; | ||
| 207 | applet_resource->FreeAppletResourceId(aruid); | ||
| 208 | } | ||
| 209 | |||
| 168 | void ResourceManager::EnableInput(u64 aruid, bool is_enabled) { | 210 | void ResourceManager::EnableInput(u64 aruid, bool is_enabled) { |
| 169 | std::scoped_lock lock{shared_mutex}; | 211 | std::scoped_lock lock{shared_mutex}; |
| 170 | applet_resource->EnableInput(aruid, is_enabled); | 212 | applet_resource->EnableInput(aruid, is_enabled); |
| @@ -189,6 +231,7 @@ void ResourceManager::UpdateControllers(std::uintptr_t user_data, | |||
| 189 | std::chrono::nanoseconds ns_late) { | 231 | std::chrono::nanoseconds ns_late) { |
| 190 | auto& core_timing = system.CoreTiming(); | 232 | auto& core_timing = system.CoreTiming(); |
| 191 | debug_pad->OnUpdate(core_timing); | 233 | debug_pad->OnUpdate(core_timing); |
| 234 | digitizer->OnUpdate(core_timing); | ||
| 192 | unique_pad->OnUpdate(core_timing); | 235 | unique_pad->OnUpdate(core_timing); |
| 193 | gesture->OnUpdate(core_timing); | 236 | gesture->OnUpdate(core_timing); |
| 194 | touch_screen->OnUpdate(core_timing); | 237 | touch_screen->OnUpdate(core_timing); |
| @@ -196,7 +239,6 @@ void ResourceManager::UpdateControllers(std::uintptr_t user_data, | |||
| 196 | home_button->OnUpdate(core_timing); | 239 | home_button->OnUpdate(core_timing); |
| 197 | sleep_button->OnUpdate(core_timing); | 240 | sleep_button->OnUpdate(core_timing); |
| 198 | capture_button->OnUpdate(core_timing); | 241 | capture_button->OnUpdate(core_timing); |
| 199 | xpad->OnUpdate(core_timing); | ||
| 200 | } | 242 | } |
| 201 | 243 | ||
| 202 | void ResourceManager::UpdateNpad(std::uintptr_t user_data, std::chrono::nanoseconds ns_late) { | 244 | void ResourceManager::UpdateNpad(std::uintptr_t user_data, std::chrono::nanoseconds ns_late) { |
| @@ -219,8 +261,10 @@ void ResourceManager::UpdateMotion(std::uintptr_t user_data, std::chrono::nanose | |||
| 219 | console_six_axis->OnUpdate(core_timing); | 261 | console_six_axis->OnUpdate(core_timing); |
| 220 | } | 262 | } |
| 221 | 263 | ||
| 222 | IAppletResource::IAppletResource(Core::System& system_, std::shared_ptr<ResourceManager> resource) | 264 | IAppletResource::IAppletResource(Core::System& system_, std::shared_ptr<ResourceManager> resource, |
| 223 | : ServiceFramework{system_, "IAppletResource"}, resource_manager{resource} { | 265 | u64 applet_resource_user_id) |
| 266 | : ServiceFramework{system_, "IAppletResource"}, aruid{applet_resource_user_id}, | ||
| 267 | resource_manager{resource} { | ||
| 224 | static const FunctionInfo functions[] = { | 268 | static const FunctionInfo functions[] = { |
| 225 | {0, &IAppletResource::GetSharedMemoryHandle, "GetSharedMemoryHandle"}, | 269 | {0, &IAppletResource::GetSharedMemoryHandle, "GetSharedMemoryHandle"}, |
| 226 | }; | 270 | }; |
| @@ -274,14 +318,14 @@ IAppletResource::~IAppletResource() { | |||
| 274 | system.CoreTiming().UnscheduleEvent(default_update_event, 0); | 318 | system.CoreTiming().UnscheduleEvent(default_update_event, 0); |
| 275 | system.CoreTiming().UnscheduleEvent(mouse_keyboard_update_event, 0); | 319 | system.CoreTiming().UnscheduleEvent(mouse_keyboard_update_event, 0); |
| 276 | system.CoreTiming().UnscheduleEvent(motion_update_event, 0); | 320 | system.CoreTiming().UnscheduleEvent(motion_update_event, 0); |
| 321 | resource_manager->FreeAppletResourceId(aruid); | ||
| 277 | } | 322 | } |
| 278 | 323 | ||
| 279 | void IAppletResource::GetSharedMemoryHandle(HLERequestContext& ctx) { | 324 | void IAppletResource::GetSharedMemoryHandle(HLERequestContext& ctx) { |
| 280 | LOG_DEBUG(Service_HID, "called"); | ||
| 281 | |||
| 282 | Kernel::KSharedMemory* handle; | 325 | Kernel::KSharedMemory* handle; |
| 283 | const u64 applet_resource_user_id = resource_manager->GetAppletResource()->GetActiveAruid(); | 326 | const auto result = resource_manager->GetSharedMemoryHandle(&handle, aruid); |
| 284 | const auto result = resource_manager->GetSharedMemoryHandle(&handle, applet_resource_user_id); | 327 | |
| 328 | LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}, result=0x{:X}", aruid, result.raw); | ||
| 285 | 329 | ||
| 286 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 330 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 287 | rb.Push(result); | 331 | rb.Push(result); |
diff --git a/src/core/hle/service/hid/resource_manager.h b/src/core/hle/service/hid/resource_manager.h index a78e2b729..5ad7cb564 100644 --- a/src/core/hle/service/hid/resource_manager.h +++ b/src/core/hle/service/hid/resource_manager.h | |||
| @@ -31,10 +31,10 @@ class Palma; | |||
| 31 | class SevenSixAxis; | 31 | class SevenSixAxis; |
| 32 | class SixAxis; | 32 | class SixAxis; |
| 33 | class TouchScreen; | 33 | class TouchScreen; |
| 34 | class XPad; | ||
| 35 | 34 | ||
| 36 | using CaptureButton = Controller_Stubbed; | 35 | using CaptureButton = Controller_Stubbed; |
| 37 | using DebugMouse = Controller_Stubbed; | 36 | using DebugMouse = Mouse; |
| 37 | using Digitizer = Controller_Stubbed; | ||
| 38 | using HomeButton = Controller_Stubbed; | 38 | using HomeButton = Controller_Stubbed; |
| 39 | using SleepButton = Controller_Stubbed; | 39 | using SleepButton = Controller_Stubbed; |
| 40 | using UniquePad = Controller_Stubbed; | 40 | using UniquePad = Controller_Stubbed; |
| @@ -46,12 +46,14 @@ public: | |||
| 46 | ~ResourceManager(); | 46 | ~ResourceManager(); |
| 47 | 47 | ||
| 48 | void Initialize(); | 48 | void Initialize(); |
| 49 | void InitializeController(u64 aruid); | ||
| 49 | 50 | ||
| 50 | std::shared_ptr<AppletResource> GetAppletResource() const; | 51 | std::shared_ptr<AppletResource> GetAppletResource() const; |
| 51 | std::shared_ptr<CaptureButton> GetCaptureButton() const; | 52 | std::shared_ptr<CaptureButton> GetCaptureButton() const; |
| 52 | std::shared_ptr<ConsoleSixAxis> GetConsoleSixAxis() const; | 53 | std::shared_ptr<ConsoleSixAxis> GetConsoleSixAxis() const; |
| 53 | std::shared_ptr<DebugMouse> GetDebugMouse() const; | 54 | std::shared_ptr<DebugMouse> GetDebugMouse() const; |
| 54 | std::shared_ptr<DebugPad> GetDebugPad() const; | 55 | std::shared_ptr<DebugPad> GetDebugPad() const; |
| 56 | std::shared_ptr<Digitizer> GetDigitizer() const; | ||
| 55 | std::shared_ptr<Gesture> GetGesture() const; | 57 | std::shared_ptr<Gesture> GetGesture() const; |
| 56 | std::shared_ptr<HomeButton> GetHomeButton() const; | 58 | std::shared_ptr<HomeButton> GetHomeButton() const; |
| 57 | std::shared_ptr<Keyboard> GetKeyboard() const; | 59 | std::shared_ptr<Keyboard> GetKeyboard() const; |
| @@ -66,10 +68,13 @@ public: | |||
| 66 | 68 | ||
| 67 | Result CreateAppletResource(u64 aruid); | 69 | Result CreateAppletResource(u64 aruid); |
| 68 | 70 | ||
| 71 | Result RegisterCoreAppletResource(); | ||
| 72 | Result UnregisterCoreAppletResource(); | ||
| 69 | Result RegisterAppletResourceUserId(u64 aruid, bool bool_value); | 73 | Result RegisterAppletResourceUserId(u64 aruid, bool bool_value); |
| 70 | void UnregisterAppletResourceUserId(u64 aruid); | 74 | void UnregisterAppletResourceUserId(u64 aruid); |
| 71 | 75 | ||
| 72 | Result GetSharedMemoryHandle(Kernel::KSharedMemory** out_handle, u64 aruid); | 76 | Result GetSharedMemoryHandle(Kernel::KSharedMemory** out_handle, u64 aruid); |
| 77 | void FreeAppletResourceId(u64 aruid); | ||
| 73 | 78 | ||
| 74 | void EnableInput(u64 aruid, bool is_enabled); | 79 | void EnableInput(u64 aruid, bool is_enabled); |
| 75 | void EnableSixAxisSensor(u64 aruid, bool is_enabled); | 80 | void EnableSixAxisSensor(u64 aruid, bool is_enabled); |
| @@ -82,6 +87,8 @@ public: | |||
| 82 | void UpdateMotion(std::uintptr_t user_data, std::chrono::nanoseconds ns_late); | 87 | void UpdateMotion(std::uintptr_t user_data, std::chrono::nanoseconds ns_late); |
| 83 | 88 | ||
| 84 | private: | 89 | private: |
| 90 | Result CreateAppletResourceImpl(u64 aruid); | ||
| 91 | |||
| 85 | bool is_initialized{false}; | 92 | bool is_initialized{false}; |
| 86 | 93 | ||
| 87 | mutable std::mutex shared_mutex; | 94 | mutable std::mutex shared_mutex; |
| @@ -91,6 +98,7 @@ private: | |||
| 91 | std::shared_ptr<ConsoleSixAxis> console_six_axis = nullptr; | 98 | std::shared_ptr<ConsoleSixAxis> console_six_axis = nullptr; |
| 92 | std::shared_ptr<DebugMouse> debug_mouse = nullptr; | 99 | std::shared_ptr<DebugMouse> debug_mouse = nullptr; |
| 93 | std::shared_ptr<DebugPad> debug_pad = nullptr; | 100 | std::shared_ptr<DebugPad> debug_pad = nullptr; |
| 101 | std::shared_ptr<Digitizer> digitizer = nullptr; | ||
| 94 | std::shared_ptr<Gesture> gesture = nullptr; | 102 | std::shared_ptr<Gesture> gesture = nullptr; |
| 95 | std::shared_ptr<HomeButton> home_button = nullptr; | 103 | std::shared_ptr<HomeButton> home_button = nullptr; |
| 96 | std::shared_ptr<Keyboard> keyboard = nullptr; | 104 | std::shared_ptr<Keyboard> keyboard = nullptr; |
| @@ -102,7 +110,6 @@ private: | |||
| 102 | std::shared_ptr<SleepButton> sleep_button = nullptr; | 110 | std::shared_ptr<SleepButton> sleep_button = nullptr; |
| 103 | std::shared_ptr<TouchScreen> touch_screen = nullptr; | 111 | std::shared_ptr<TouchScreen> touch_screen = nullptr; |
| 104 | std::shared_ptr<UniquePad> unique_pad = nullptr; | 112 | std::shared_ptr<UniquePad> unique_pad = nullptr; |
| 105 | std::shared_ptr<XPad> xpad = nullptr; | ||
| 106 | 113 | ||
| 107 | // TODO: Create these resources | 114 | // TODO: Create these resources |
| 108 | // std::shared_ptr<AudioControl> audio_control = nullptr; | 115 | // std::shared_ptr<AudioControl> audio_control = nullptr; |
| @@ -121,7 +128,8 @@ private: | |||
| 121 | 128 | ||
| 122 | class IAppletResource final : public ServiceFramework<IAppletResource> { | 129 | class IAppletResource final : public ServiceFramework<IAppletResource> { |
| 123 | public: | 130 | public: |
| 124 | explicit IAppletResource(Core::System& system_, std::shared_ptr<ResourceManager> resource); | 131 | explicit IAppletResource(Core::System& system_, std::shared_ptr<ResourceManager> resource, |
| 132 | u64 applet_resource_user_id); | ||
| 125 | ~IAppletResource() override; | 133 | ~IAppletResource() override; |
| 126 | 134 | ||
| 127 | private: | 135 | private: |
| @@ -132,6 +140,7 @@ private: | |||
| 132 | std::shared_ptr<Core::Timing::EventType> mouse_keyboard_update_event; | 140 | std::shared_ptr<Core::Timing::EventType> mouse_keyboard_update_event; |
| 133 | std::shared_ptr<Core::Timing::EventType> motion_update_event; | 141 | std::shared_ptr<Core::Timing::EventType> motion_update_event; |
| 134 | 142 | ||
| 143 | u64 aruid; | ||
| 135 | std::shared_ptr<ResourceManager> resource_manager; | 144 | std::shared_ptr<ResourceManager> resource_manager; |
| 136 | }; | 145 | }; |
| 137 | 146 | ||
diff --git a/src/core/hle/service/hle_ipc.cpp b/src/core/hle/service/hle_ipc.cpp index ff374ae39..38955932c 100644 --- a/src/core/hle/service/hle_ipc.cpp +++ b/src/core/hle/service/hle_ipc.cpp | |||
| @@ -146,8 +146,10 @@ HLERequestContext::HLERequestContext(Kernel::KernelCore& kernel_, Core::Memory:: | |||
| 146 | 146 | ||
| 147 | HLERequestContext::~HLERequestContext() = default; | 147 | HLERequestContext::~HLERequestContext() = default; |
| 148 | 148 | ||
| 149 | void HLERequestContext::ParseCommandBuffer(const Kernel::KHandleTable& handle_table, | 149 | void HLERequestContext::ParseCommandBuffer(Kernel::KProcess& process, u32_le* src_cmdbuf, |
| 150 | u32_le* src_cmdbuf, bool incoming) { | 150 | bool incoming) { |
| 151 | client_handle_table = &process.GetHandleTable(); | ||
| 152 | |||
| 151 | IPC::RequestParser rp(src_cmdbuf); | 153 | IPC::RequestParser rp(src_cmdbuf); |
| 152 | command_header = rp.PopRaw<IPC::CommandHeader>(); | 154 | command_header = rp.PopRaw<IPC::CommandHeader>(); |
| 153 | 155 | ||
| @@ -160,7 +162,8 @@ void HLERequestContext::ParseCommandBuffer(const Kernel::KHandleTable& handle_ta | |||
| 160 | if (command_header->enable_handle_descriptor) { | 162 | if (command_header->enable_handle_descriptor) { |
| 161 | handle_descriptor_header = rp.PopRaw<IPC::HandleDescriptorHeader>(); | 163 | handle_descriptor_header = rp.PopRaw<IPC::HandleDescriptorHeader>(); |
| 162 | if (handle_descriptor_header->send_current_pid) { | 164 | if (handle_descriptor_header->send_current_pid) { |
| 163 | pid = rp.Pop<u64>(); | 165 | pid = process.GetProcessId(); |
| 166 | rp.Skip(2, false); | ||
| 164 | } | 167 | } |
| 165 | if (incoming) { | 168 | if (incoming) { |
| 166 | // Populate the object lists with the data in the IPC request. | 169 | // Populate the object lists with the data in the IPC request. |
| @@ -267,9 +270,9 @@ void HLERequestContext::ParseCommandBuffer(const Kernel::KHandleTable& handle_ta | |||
| 267 | rp.Skip(1, false); // The command is actually an u64, but we don't use the high part. | 270 | rp.Skip(1, false); // The command is actually an u64, but we don't use the high part. |
| 268 | } | 271 | } |
| 269 | 272 | ||
| 270 | Result HLERequestContext::PopulateFromIncomingCommandBuffer( | 273 | Result HLERequestContext::PopulateFromIncomingCommandBuffer(Kernel::KProcess& process, |
| 271 | const Kernel::KHandleTable& handle_table, u32_le* src_cmdbuf) { | 274 | u32_le* src_cmdbuf) { |
| 272 | ParseCommandBuffer(handle_table, src_cmdbuf, true); | 275 | ParseCommandBuffer(process, src_cmdbuf, true); |
| 273 | 276 | ||
| 274 | if (command_header->IsCloseCommand()) { | 277 | if (command_header->IsCloseCommand()) { |
| 275 | // Close does not populate the rest of the IPC header | 278 | // Close does not populate the rest of the IPC header |
diff --git a/src/core/hle/service/hle_ipc.h b/src/core/hle/service/hle_ipc.h index ad5259a5c..18d464c63 100644 --- a/src/core/hle/service/hle_ipc.h +++ b/src/core/hle/service/hle_ipc.h | |||
| @@ -38,6 +38,7 @@ namespace Kernel { | |||
| 38 | class KAutoObject; | 38 | class KAutoObject; |
| 39 | class KernelCore; | 39 | class KernelCore; |
| 40 | class KHandleTable; | 40 | class KHandleTable; |
| 41 | class KProcess; | ||
| 41 | class KServerSession; | 42 | class KServerSession; |
| 42 | class KThread; | 43 | class KThread; |
| 43 | } // namespace Kernel | 44 | } // namespace Kernel |
| @@ -75,6 +76,7 @@ protected: | |||
| 75 | 76 | ||
| 76 | using SessionRequestHandlerWeakPtr = std::weak_ptr<SessionRequestHandler>; | 77 | using SessionRequestHandlerWeakPtr = std::weak_ptr<SessionRequestHandler>; |
| 77 | using SessionRequestHandlerPtr = std::shared_ptr<SessionRequestHandler>; | 78 | using SessionRequestHandlerPtr = std::shared_ptr<SessionRequestHandler>; |
| 79 | using SessionRequestHandlerFactory = std::function<SessionRequestHandlerPtr()>; | ||
| 78 | 80 | ||
| 79 | /** | 81 | /** |
| 80 | * Manages the underlying HLE requests for a session, and whether (or not) the session should be | 82 | * Manages the underlying HLE requests for a session, and whether (or not) the session should be |
| @@ -194,8 +196,7 @@ public: | |||
| 194 | } | 196 | } |
| 195 | 197 | ||
| 196 | /// Populates this context with data from the requesting process/thread. | 198 | /// Populates this context with data from the requesting process/thread. |
| 197 | Result PopulateFromIncomingCommandBuffer(const Kernel::KHandleTable& handle_table, | 199 | Result PopulateFromIncomingCommandBuffer(Kernel::KProcess& process, u32_le* src_cmdbuf); |
| 198 | u32_le* src_cmdbuf); | ||
| 199 | 200 | ||
| 200 | /// Writes data from this context back to the requesting process/thread. | 201 | /// Writes data from this context back to the requesting process/thread. |
| 201 | Result WriteToOutgoingCommandBuffer(Kernel::KThread& requesting_thread); | 202 | Result WriteToOutgoingCommandBuffer(Kernel::KThread& requesting_thread); |
| @@ -358,6 +359,10 @@ public: | |||
| 358 | return *thread; | 359 | return *thread; |
| 359 | } | 360 | } |
| 360 | 361 | ||
| 362 | Kernel::KHandleTable& GetClientHandleTable() { | ||
| 363 | return *client_handle_table; | ||
| 364 | } | ||
| 365 | |||
| 361 | [[nodiscard]] std::shared_ptr<SessionRequestManager> GetManager() const { | 366 | [[nodiscard]] std::shared_ptr<SessionRequestManager> GetManager() const { |
| 362 | return manager.lock(); | 367 | return manager.lock(); |
| 363 | } | 368 | } |
| @@ -373,12 +378,12 @@ public: | |||
| 373 | private: | 378 | private: |
| 374 | friend class IPC::ResponseBuilder; | 379 | friend class IPC::ResponseBuilder; |
| 375 | 380 | ||
| 376 | void ParseCommandBuffer(const Kernel::KHandleTable& handle_table, u32_le* src_cmdbuf, | 381 | void ParseCommandBuffer(Kernel::KProcess& process, u32_le* src_cmdbuf, bool incoming); |
| 377 | bool incoming); | ||
| 378 | 382 | ||
| 379 | std::array<u32, IPC::COMMAND_BUFFER_LENGTH> cmd_buf; | 383 | std::array<u32, IPC::COMMAND_BUFFER_LENGTH> cmd_buf; |
| 380 | Kernel::KServerSession* server_session{}; | 384 | Kernel::KServerSession* server_session{}; |
| 381 | Kernel::KThread* thread; | 385 | Kernel::KHandleTable* client_handle_table{}; |
| 386 | Kernel::KThread* thread{}; | ||
| 382 | 387 | ||
| 383 | std::vector<Handle> incoming_move_handles; | 388 | std::vector<Handle> incoming_move_handles; |
| 384 | std::vector<Handle> incoming_copy_handles; | 389 | std::vector<Handle> incoming_copy_handles; |
diff --git a/src/core/hle/service/ldr/ldr.cpp b/src/core/hle/service/ldr/ldr.cpp index 97b6a9385..ba58b3a09 100644 --- a/src/core/hle/service/ldr/ldr.cpp +++ b/src/core/hle/service/ldr/ldr.cpp | |||
| @@ -1,117 +1,12 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include <memory> | ||
| 5 | #include <fmt/format.h> | ||
| 6 | #include <mbedtls/sha256.h> | ||
| 7 | |||
| 8 | #include "common/alignment.h" | ||
| 9 | #include "common/hex_util.h" | ||
| 10 | #include "common/scope_exit.h" | ||
| 11 | #include "core/core.h" | ||
| 12 | #include "core/hle/kernel/k_page_table.h" | ||
| 13 | #include "core/hle/kernel/svc_results.h" | ||
| 14 | #include "core/hle/kernel/svc_types.h" | ||
| 15 | #include "core/hle/service/ipc_helpers.h" | ||
| 16 | #include "core/hle/service/ldr/ldr.h" | 4 | #include "core/hle/service/ldr/ldr.h" |
| 17 | #include "core/hle/service/server_manager.h" | 5 | #include "core/hle/service/server_manager.h" |
| 18 | #include "core/hle/service/service.h" | 6 | #include "core/hle/service/service.h" |
| 19 | #include "core/loader/nro.h" | ||
| 20 | #include "core/memory.h" | ||
| 21 | 7 | ||
| 22 | namespace Service::LDR { | 8 | namespace Service::LDR { |
| 23 | 9 | ||
| 24 | constexpr Result ERROR_INSUFFICIENT_ADDRESS_SPACE{ErrorModule::RO, 2}; | ||
| 25 | |||
| 26 | [[maybe_unused]] constexpr Result ERROR_INVALID_MEMORY_STATE{ErrorModule::Loader, 51}; | ||
| 27 | constexpr Result ERROR_INVALID_NRO{ErrorModule::Loader, 52}; | ||
| 28 | constexpr Result ERROR_INVALID_NRR{ErrorModule::Loader, 53}; | ||
| 29 | constexpr Result ERROR_MISSING_NRR_HASH{ErrorModule::Loader, 54}; | ||
| 30 | constexpr Result ERROR_MAXIMUM_NRO{ErrorModule::Loader, 55}; | ||
| 31 | constexpr Result ERROR_MAXIMUM_NRR{ErrorModule::Loader, 56}; | ||
| 32 | constexpr Result ERROR_ALREADY_LOADED{ErrorModule::Loader, 57}; | ||
| 33 | constexpr Result ERROR_INVALID_ALIGNMENT{ErrorModule::Loader, 81}; | ||
| 34 | constexpr Result ERROR_INVALID_SIZE{ErrorModule::Loader, 82}; | ||
| 35 | constexpr Result ERROR_INVALID_NRO_ADDRESS{ErrorModule::Loader, 84}; | ||
| 36 | [[maybe_unused]] constexpr Result ERROR_INVALID_NRR_ADDRESS{ErrorModule::Loader, 85}; | ||
| 37 | constexpr Result ERROR_NOT_INITIALIZED{ErrorModule::Loader, 87}; | ||
| 38 | |||
| 39 | constexpr std::size_t MAXIMUM_LOADED_RO{0x40}; | ||
| 40 | constexpr std::size_t MAXIMUM_MAP_RETRIES{0x200}; | ||
| 41 | |||
| 42 | constexpr std::size_t TEXT_INDEX{0}; | ||
| 43 | constexpr std::size_t RO_INDEX{1}; | ||
| 44 | constexpr std::size_t DATA_INDEX{2}; | ||
| 45 | |||
| 46 | struct NRRCertification { | ||
| 47 | u64_le application_id_mask; | ||
| 48 | u64_le application_id_pattern; | ||
| 49 | INSERT_PADDING_BYTES(0x10); | ||
| 50 | std::array<u8, 0x100> public_key; // Also known as modulus | ||
| 51 | std::array<u8, 0x100> signature; | ||
| 52 | }; | ||
| 53 | static_assert(sizeof(NRRCertification) == 0x220, "NRRCertification has invalid size."); | ||
| 54 | |||
| 55 | struct NRRHeader { | ||
| 56 | u32_le magic; | ||
| 57 | u32_le certification_signature_key_generation; // 9.0.0+ | ||
| 58 | INSERT_PADDING_WORDS(2); | ||
| 59 | NRRCertification certification; | ||
| 60 | std::array<u8, 0x100> signature; | ||
| 61 | u64_le application_id; | ||
| 62 | u32_le size; | ||
| 63 | u8 nrr_kind; // 7.0.0+ | ||
| 64 | INSERT_PADDING_BYTES(3); | ||
| 65 | u32_le hash_offset; | ||
| 66 | u32_le hash_count; | ||
| 67 | INSERT_PADDING_WORDS(2); | ||
| 68 | }; | ||
| 69 | static_assert(sizeof(NRRHeader) == 0x350, "NRRHeader has invalid size."); | ||
| 70 | |||
| 71 | struct SegmentHeader { | ||
| 72 | u32_le memory_offset; | ||
| 73 | u32_le memory_size; | ||
| 74 | }; | ||
| 75 | static_assert(sizeof(SegmentHeader) == 0x8, "SegmentHeader has invalid size."); | ||
| 76 | |||
| 77 | struct NROHeader { | ||
| 78 | // Switchbrew calls this "Start" (0x10) | ||
| 79 | INSERT_PADDING_WORDS(1); | ||
| 80 | u32_le mod_offset; | ||
| 81 | INSERT_PADDING_WORDS(2); | ||
| 82 | |||
| 83 | // Switchbrew calls this "Header" (0x70) | ||
| 84 | u32_le magic; | ||
| 85 | u32_le version; | ||
| 86 | u32_le nro_size; | ||
| 87 | u32_le flags; | ||
| 88 | // .text, .ro, .data | ||
| 89 | std::array<SegmentHeader, 3> segment_headers; | ||
| 90 | u32_le bss_size; | ||
| 91 | INSERT_PADDING_WORDS(1); | ||
| 92 | std::array<u8, 0x20> build_id; | ||
| 93 | u32_le dso_handle_offset; | ||
| 94 | INSERT_PADDING_WORDS(1); | ||
| 95 | // .apiInfo, .dynstr, .dynsym | ||
| 96 | std::array<SegmentHeader, 3> segment_headers_2; | ||
| 97 | }; | ||
| 98 | static_assert(sizeof(NROHeader) == 0x80, "NROHeader has invalid size."); | ||
| 99 | |||
| 100 | using SHA256Hash = std::array<u8, 0x20>; | ||
| 101 | |||
| 102 | struct NROInfo { | ||
| 103 | SHA256Hash hash{}; | ||
| 104 | VAddr nro_address{}; | ||
| 105 | std::size_t nro_size{}; | ||
| 106 | VAddr bss_address{}; | ||
| 107 | std::size_t bss_size{}; | ||
| 108 | std::size_t text_size{}; | ||
| 109 | std::size_t ro_size{}; | ||
| 110 | std::size_t data_size{}; | ||
| 111 | VAddr src_addr{}; | ||
| 112 | }; | ||
| 113 | static_assert(sizeof(NROInfo) == 0x60, "NROInfo has invalid size."); | ||
| 114 | |||
| 115 | class DebugMonitor final : public ServiceFramework<DebugMonitor> { | 10 | class DebugMonitor final : public ServiceFramework<DebugMonitor> { |
| 116 | public: | 11 | public: |
| 117 | explicit DebugMonitor(Core::System& system_) : ServiceFramework{system_, "ldr:dmnt"} { | 12 | explicit DebugMonitor(Core::System& system_) : ServiceFramework{system_, "ldr:dmnt"} { |
| @@ -158,541 +53,12 @@ public: | |||
| 158 | } | 53 | } |
| 159 | }; | 54 | }; |
| 160 | 55 | ||
| 161 | class RelocatableObject final : public ServiceFramework<RelocatableObject> { | ||
| 162 | public: | ||
| 163 | explicit RelocatableObject(Core::System& system_) : ServiceFramework{system_, "ldr:ro"} { | ||
| 164 | // clang-format off | ||
| 165 | static const FunctionInfo functions[] = { | ||
| 166 | {0, &RelocatableObject::LoadModule, "LoadModule"}, | ||
| 167 | {1, &RelocatableObject::UnloadModule, "UnloadModule"}, | ||
| 168 | {2, &RelocatableObject::RegisterModuleInfo, "RegisterModuleInfo"}, | ||
| 169 | {3, &RelocatableObject::UnregisterModuleInfo, "UnregisterModuleInfo"}, | ||
| 170 | {4, &RelocatableObject::Initialize, "Initialize"}, | ||
| 171 | {10, nullptr, "RegisterModuleInfo2"}, | ||
| 172 | }; | ||
| 173 | // clang-format on | ||
| 174 | |||
| 175 | RegisterHandlers(functions); | ||
| 176 | } | ||
| 177 | |||
| 178 | void RegisterModuleInfo(HLERequestContext& ctx) { | ||
| 179 | struct Parameters { | ||
| 180 | u64_le process_id; | ||
| 181 | u64_le nrr_address; | ||
| 182 | u64_le nrr_size; | ||
| 183 | }; | ||
| 184 | |||
| 185 | IPC::RequestParser rp{ctx}; | ||
| 186 | const auto [process_id, nrr_address, nrr_size] = rp.PopRaw<Parameters>(); | ||
| 187 | |||
| 188 | LOG_DEBUG(Service_LDR, | ||
| 189 | "called with process_id={:016X}, nrr_address={:016X}, nrr_size={:016X}", | ||
| 190 | process_id, nrr_address, nrr_size); | ||
| 191 | |||
| 192 | if (!initialized) { | ||
| 193 | LOG_ERROR(Service_LDR, "LDR:RO not initialized before use!"); | ||
| 194 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 195 | rb.Push(ERROR_NOT_INITIALIZED); | ||
| 196 | return; | ||
| 197 | } | ||
| 198 | |||
| 199 | if (nrr.size() >= MAXIMUM_LOADED_RO) { | ||
| 200 | LOG_ERROR(Service_LDR, "Loading new NRR would exceed the maximum number of loaded NRRs " | ||
| 201 | "(0x40)! Failing..."); | ||
| 202 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 203 | rb.Push(ERROR_MAXIMUM_NRR); | ||
| 204 | return; | ||
| 205 | } | ||
| 206 | |||
| 207 | // NRR Address does not fall on 0x1000 byte boundary | ||
| 208 | if (!Common::Is4KBAligned(nrr_address)) { | ||
| 209 | LOG_ERROR(Service_LDR, "NRR Address has invalid alignment (actual {:016X})!", | ||
| 210 | nrr_address); | ||
| 211 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 212 | rb.Push(ERROR_INVALID_ALIGNMENT); | ||
| 213 | return; | ||
| 214 | } | ||
| 215 | |||
| 216 | // NRR Size is zero or causes overflow | ||
| 217 | if (nrr_address + nrr_size <= nrr_address || nrr_size == 0 || | ||
| 218 | !Common::Is4KBAligned(nrr_size)) { | ||
| 219 | LOG_ERROR(Service_LDR, "NRR Size is invalid! (nrr_address={:016X}, nrr_size={:016X})", | ||
| 220 | nrr_address, nrr_size); | ||
| 221 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 222 | rb.Push(ERROR_INVALID_SIZE); | ||
| 223 | return; | ||
| 224 | } | ||
| 225 | |||
| 226 | // Read NRR data from memory | ||
| 227 | std::vector<u8> nrr_data(nrr_size); | ||
| 228 | system.ApplicationMemory().ReadBlock(nrr_address, nrr_data.data(), nrr_size); | ||
| 229 | NRRHeader header; | ||
| 230 | std::memcpy(&header, nrr_data.data(), sizeof(NRRHeader)); | ||
| 231 | |||
| 232 | if (header.magic != Common::MakeMagic('N', 'R', 'R', '0')) { | ||
| 233 | LOG_ERROR(Service_LDR, "NRR did not have magic 'NRR0' (actual {:08X})!", header.magic); | ||
| 234 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 235 | rb.Push(ERROR_INVALID_NRR); | ||
| 236 | return; | ||
| 237 | } | ||
| 238 | |||
| 239 | if (header.size != nrr_size) { | ||
| 240 | LOG_ERROR(Service_LDR, | ||
| 241 | "NRR header reported size did not match LoadNrr parameter size! " | ||
| 242 | "(header_size={:016X}, loadnrr_size={:016X})", | ||
| 243 | header.size, nrr_size); | ||
| 244 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 245 | rb.Push(ERROR_INVALID_SIZE); | ||
| 246 | return; | ||
| 247 | } | ||
| 248 | |||
| 249 | if (system.GetApplicationProcessProgramID() != header.application_id) { | ||
| 250 | LOG_ERROR(Service_LDR, | ||
| 251 | "Attempting to load NRR with title ID other than current process. (actual " | ||
| 252 | "{:016X})!", | ||
| 253 | header.application_id); | ||
| 254 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 255 | rb.Push(ERROR_INVALID_NRR); | ||
| 256 | return; | ||
| 257 | } | ||
| 258 | |||
| 259 | std::vector<SHA256Hash> hashes; | ||
| 260 | |||
| 261 | // Copy all hashes in the NRR (specified by hash count/hash offset) into vector. | ||
| 262 | for (std::size_t i = header.hash_offset; | ||
| 263 | i < (header.hash_offset + (header.hash_count * sizeof(SHA256Hash))); i += 8) { | ||
| 264 | SHA256Hash hash; | ||
| 265 | std::memcpy(hash.data(), nrr_data.data() + i, sizeof(SHA256Hash)); | ||
| 266 | hashes.emplace_back(hash); | ||
| 267 | } | ||
| 268 | |||
| 269 | nrr.insert_or_assign(nrr_address, std::move(hashes)); | ||
| 270 | |||
| 271 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 272 | rb.Push(ResultSuccess); | ||
| 273 | } | ||
| 274 | |||
| 275 | void UnregisterModuleInfo(HLERequestContext& ctx) { | ||
| 276 | IPC::RequestParser rp{ctx}; | ||
| 277 | const auto pid = rp.Pop<u64>(); | ||
| 278 | const auto nrr_address = rp.Pop<VAddr>(); | ||
| 279 | |||
| 280 | LOG_DEBUG(Service_LDR, "called with pid={}, nrr_address={:016X}", pid, nrr_address); | ||
| 281 | |||
| 282 | nrr.erase(nrr_address); | ||
| 283 | |||
| 284 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 285 | |||
| 286 | rb.Push(ResultSuccess); | ||
| 287 | } | ||
| 288 | |||
| 289 | bool ValidateRegionForMap(Kernel::KProcessPageTable& page_table, VAddr start, | ||
| 290 | std::size_t size) const { | ||
| 291 | const std::size_t padding_size{page_table.GetNumGuardPages() * Kernel::PageSize}; | ||
| 292 | |||
| 293 | Kernel::KMemoryInfo start_info; | ||
| 294 | Kernel::Svc::PageInfo page_info; | ||
| 295 | R_ASSERT( | ||
| 296 | page_table.QueryInfo(std::addressof(start_info), std::addressof(page_info), start - 1)); | ||
| 297 | |||
| 298 | if (start_info.GetState() != Kernel::KMemoryState::Free) { | ||
| 299 | return {}; | ||
| 300 | } | ||
| 301 | |||
| 302 | if (start_info.GetAddress() > (start - padding_size)) { | ||
| 303 | return {}; | ||
| 304 | } | ||
| 305 | |||
| 306 | Kernel::KMemoryInfo end_info; | ||
| 307 | R_ASSERT(page_table.QueryInfo(std::addressof(end_info), std::addressof(page_info), | ||
| 308 | start + size)); | ||
| 309 | |||
| 310 | if (end_info.GetState() != Kernel::KMemoryState::Free) { | ||
| 311 | return {}; | ||
| 312 | } | ||
| 313 | |||
| 314 | return (start + size + padding_size) <= (end_info.GetAddress() + end_info.GetSize()); | ||
| 315 | } | ||
| 316 | |||
| 317 | Result GetAvailableMapRegion(Kernel::KProcessPageTable& page_table, u64 size, VAddr& out_addr) { | ||
| 318 | size = Common::AlignUp(size, Kernel::PageSize); | ||
| 319 | size += page_table.GetNumGuardPages() * Kernel::PageSize * 4; | ||
| 320 | |||
| 321 | const auto is_region_available = [&](VAddr addr) { | ||
| 322 | const auto end_addr = addr + size; | ||
| 323 | while (addr < end_addr) { | ||
| 324 | if (system.ApplicationMemory().IsValidVirtualAddress(addr)) { | ||
| 325 | return false; | ||
| 326 | } | ||
| 327 | |||
| 328 | if (!page_table.Contains(out_addr, size)) { | ||
| 329 | return false; | ||
| 330 | } | ||
| 331 | |||
| 332 | if (page_table.IsInHeapRegion(out_addr, size)) { | ||
| 333 | return false; | ||
| 334 | } | ||
| 335 | |||
| 336 | if (page_table.IsInAliasRegion(out_addr, size)) { | ||
| 337 | return false; | ||
| 338 | } | ||
| 339 | |||
| 340 | addr += Kernel::PageSize; | ||
| 341 | } | ||
| 342 | return true; | ||
| 343 | }; | ||
| 344 | |||
| 345 | bool succeeded = false; | ||
| 346 | const auto map_region_end = | ||
| 347 | GetInteger(page_table.GetAliasCodeRegionStart()) + page_table.GetAliasCodeRegionSize(); | ||
| 348 | while (current_map_addr < map_region_end) { | ||
| 349 | if (is_region_available(current_map_addr)) { | ||
| 350 | succeeded = true; | ||
| 351 | break; | ||
| 352 | } | ||
| 353 | current_map_addr += 0x100000; | ||
| 354 | } | ||
| 355 | |||
| 356 | if (!succeeded) { | ||
| 357 | ASSERT_MSG(false, "Out of address space!"); | ||
| 358 | return Kernel::ResultOutOfMemory; | ||
| 359 | } | ||
| 360 | |||
| 361 | out_addr = current_map_addr; | ||
| 362 | current_map_addr += size; | ||
| 363 | |||
| 364 | return ResultSuccess; | ||
| 365 | } | ||
| 366 | |||
| 367 | Result MapProcessCodeMemory(VAddr* out_map_location, Kernel::KProcess* process, VAddr base_addr, | ||
| 368 | u64 size) { | ||
| 369 | auto& page_table{process->GetPageTable()}; | ||
| 370 | VAddr addr{}; | ||
| 371 | |||
| 372 | for (std::size_t retry = 0; retry < MAXIMUM_MAP_RETRIES; retry++) { | ||
| 373 | R_TRY(GetAvailableMapRegion(page_table, size, addr)); | ||
| 374 | |||
| 375 | const Result result{page_table.MapCodeMemory(addr, base_addr, size)}; | ||
| 376 | if (result == Kernel::ResultInvalidCurrentMemory) { | ||
| 377 | continue; | ||
| 378 | } | ||
| 379 | |||
| 380 | R_TRY(result); | ||
| 381 | |||
| 382 | if (ValidateRegionForMap(page_table, addr, size)) { | ||
| 383 | *out_map_location = addr; | ||
| 384 | return ResultSuccess; | ||
| 385 | } | ||
| 386 | } | ||
| 387 | |||
| 388 | return ERROR_INSUFFICIENT_ADDRESS_SPACE; | ||
| 389 | } | ||
| 390 | |||
| 391 | Result MapNro(VAddr* out_map_location, Kernel::KProcess* process, VAddr nro_addr, | ||
| 392 | std::size_t nro_size, VAddr bss_addr, std::size_t bss_size, std::size_t size) { | ||
| 393 | for (std::size_t retry = 0; retry < MAXIMUM_MAP_RETRIES; retry++) { | ||
| 394 | auto& page_table{process->GetPageTable()}; | ||
| 395 | VAddr addr{}; | ||
| 396 | |||
| 397 | R_TRY(MapProcessCodeMemory(&addr, process, nro_addr, nro_size)); | ||
| 398 | |||
| 399 | if (bss_size) { | ||
| 400 | auto block_guard = detail::ScopeExit([&] { | ||
| 401 | page_table.UnmapCodeMemory(addr + nro_size, bss_addr, bss_size); | ||
| 402 | page_table.UnmapCodeMemory(addr, nro_addr, nro_size); | ||
| 403 | }); | ||
| 404 | |||
| 405 | const Result result{page_table.MapCodeMemory(addr + nro_size, bss_addr, bss_size)}; | ||
| 406 | |||
| 407 | if (result == Kernel::ResultInvalidCurrentMemory) { | ||
| 408 | continue; | ||
| 409 | } | ||
| 410 | |||
| 411 | if (result.IsError()) { | ||
| 412 | return result; | ||
| 413 | } | ||
| 414 | |||
| 415 | block_guard.Cancel(); | ||
| 416 | } | ||
| 417 | |||
| 418 | if (ValidateRegionForMap(page_table, addr, size)) { | ||
| 419 | *out_map_location = addr; | ||
| 420 | return ResultSuccess; | ||
| 421 | } | ||
| 422 | } | ||
| 423 | |||
| 424 | return ERROR_INSUFFICIENT_ADDRESS_SPACE; | ||
| 425 | } | ||
| 426 | |||
| 427 | Result LoadNro(Kernel::KProcess* process, const NROHeader& nro_header, VAddr nro_addr, | ||
| 428 | VAddr start) const { | ||
| 429 | const VAddr text_start{start + nro_header.segment_headers[TEXT_INDEX].memory_offset}; | ||
| 430 | const VAddr ro_start{start + nro_header.segment_headers[RO_INDEX].memory_offset}; | ||
| 431 | const VAddr data_start{start + nro_header.segment_headers[DATA_INDEX].memory_offset}; | ||
| 432 | const VAddr bss_start{data_start + nro_header.segment_headers[DATA_INDEX].memory_size}; | ||
| 433 | const VAddr bss_end_addr{ | ||
| 434 | Common::AlignUp(bss_start + nro_header.bss_size, Kernel::PageSize)}; | ||
| 435 | |||
| 436 | const auto CopyCode = [this](VAddr src_addr, VAddr dst_addr, u64 size) { | ||
| 437 | system.ApplicationMemory().CopyBlock(dst_addr, src_addr, size); | ||
| 438 | }; | ||
| 439 | CopyCode(nro_addr + nro_header.segment_headers[TEXT_INDEX].memory_offset, text_start, | ||
| 440 | nro_header.segment_headers[TEXT_INDEX].memory_size); | ||
| 441 | CopyCode(nro_addr + nro_header.segment_headers[RO_INDEX].memory_offset, ro_start, | ||
| 442 | nro_header.segment_headers[RO_INDEX].memory_size); | ||
| 443 | CopyCode(nro_addr + nro_header.segment_headers[DATA_INDEX].memory_offset, data_start, | ||
| 444 | nro_header.segment_headers[DATA_INDEX].memory_size); | ||
| 445 | |||
| 446 | R_TRY(process->GetPageTable().SetProcessMemoryPermission( | ||
| 447 | text_start, ro_start - text_start, Kernel::Svc::MemoryPermission::ReadExecute)); | ||
| 448 | R_TRY(process->GetPageTable().SetProcessMemoryPermission( | ||
| 449 | ro_start, data_start - ro_start, Kernel::Svc::MemoryPermission::Read)); | ||
| 450 | |||
| 451 | return process->GetPageTable().SetProcessMemoryPermission( | ||
| 452 | data_start, bss_end_addr - data_start, Kernel::Svc::MemoryPermission::ReadWrite); | ||
| 453 | } | ||
| 454 | |||
| 455 | void LoadModule(HLERequestContext& ctx) { | ||
| 456 | struct Parameters { | ||
| 457 | u64_le process_id; | ||
| 458 | u64_le image_address; | ||
| 459 | u64_le image_size; | ||
| 460 | u64_le bss_address; | ||
| 461 | u64_le bss_size; | ||
| 462 | }; | ||
| 463 | |||
| 464 | IPC::RequestParser rp{ctx}; | ||
| 465 | const auto [process_id, nro_address, nro_size, bss_address, bss_size] = | ||
| 466 | rp.PopRaw<Parameters>(); | ||
| 467 | |||
| 468 | LOG_DEBUG(Service_LDR, | ||
| 469 | "called with pid={:016X}, nro_addr={:016X}, nro_size={:016X}, bss_addr={:016X}, " | ||
| 470 | "bss_size={:016X}", | ||
| 471 | process_id, nro_address, nro_size, bss_address, bss_size); | ||
| 472 | |||
| 473 | if (!initialized) { | ||
| 474 | LOG_ERROR(Service_LDR, "LDR:RO not initialized before use!"); | ||
| 475 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 476 | rb.Push(ERROR_NOT_INITIALIZED); | ||
| 477 | return; | ||
| 478 | } | ||
| 479 | |||
| 480 | if (nro.size() >= MAXIMUM_LOADED_RO) { | ||
| 481 | LOG_ERROR(Service_LDR, "Loading new NRO would exceed the maximum number of loaded NROs " | ||
| 482 | "(0x40)! Failing..."); | ||
| 483 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 484 | rb.Push(ERROR_MAXIMUM_NRO); | ||
| 485 | return; | ||
| 486 | } | ||
| 487 | |||
| 488 | // NRO Address does not fall on 0x1000 byte boundary | ||
| 489 | if (!Common::Is4KBAligned(nro_address)) { | ||
| 490 | LOG_ERROR(Service_LDR, "NRO Address has invalid alignment (actual {:016X})!", | ||
| 491 | nro_address); | ||
| 492 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 493 | rb.Push(ERROR_INVALID_ALIGNMENT); | ||
| 494 | return; | ||
| 495 | } | ||
| 496 | |||
| 497 | // NRO Size or BSS Size is zero or causes overflow | ||
| 498 | const auto nro_size_valid = | ||
| 499 | nro_size != 0 && nro_address + nro_size > nro_address && Common::Is4KBAligned(nro_size); | ||
| 500 | const auto bss_size_valid = nro_size + bss_size >= nro_size && | ||
| 501 | (bss_size == 0 || bss_address + bss_size > bss_address); | ||
| 502 | |||
| 503 | if (!nro_size_valid || !bss_size_valid) { | ||
| 504 | LOG_ERROR(Service_LDR, | ||
| 505 | "NRO Size or BSS Size is invalid! (nro_address={:016X}, nro_size={:016X}, " | ||
| 506 | "bss_address={:016X}, bss_size={:016X})", | ||
| 507 | nro_address, nro_size, bss_address, bss_size); | ||
| 508 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 509 | rb.Push(ERROR_INVALID_SIZE); | ||
| 510 | return; | ||
| 511 | } | ||
| 512 | |||
| 513 | // Read NRO data from memory | ||
| 514 | std::vector<u8> nro_data(nro_size); | ||
| 515 | system.ApplicationMemory().ReadBlock(nro_address, nro_data.data(), nro_size); | ||
| 516 | |||
| 517 | SHA256Hash hash{}; | ||
| 518 | mbedtls_sha256_ret(nro_data.data(), nro_data.size(), hash.data(), 0); | ||
| 519 | |||
| 520 | // NRO Hash is already loaded | ||
| 521 | if (std::any_of(nro.begin(), nro.end(), [&hash](const std::pair<VAddr, NROInfo>& info) { | ||
| 522 | return info.second.hash == hash; | ||
| 523 | })) { | ||
| 524 | LOG_ERROR(Service_LDR, "NRO is already loaded!"); | ||
| 525 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 526 | rb.Push(ERROR_ALREADY_LOADED); | ||
| 527 | return; | ||
| 528 | } | ||
| 529 | |||
| 530 | // NRO Hash is not in any loaded NRR | ||
| 531 | if (!IsValidNROHash(hash)) { | ||
| 532 | LOG_ERROR(Service_LDR, | ||
| 533 | "NRO hash is not present in any currently loaded NRRs (hash={})!", | ||
| 534 | Common::HexToString(hash)); | ||
| 535 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 536 | rb.Push(ERROR_MISSING_NRR_HASH); | ||
| 537 | return; | ||
| 538 | } | ||
| 539 | |||
| 540 | // Load and validate the NRO header | ||
| 541 | NROHeader header{}; | ||
| 542 | std::memcpy(&header, nro_data.data(), sizeof(NROHeader)); | ||
| 543 | if (!IsValidNRO(header, nro_size, bss_size)) { | ||
| 544 | LOG_ERROR(Service_LDR, "NRO was invalid!"); | ||
| 545 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 546 | rb.Push(ERROR_INVALID_NRO); | ||
| 547 | return; | ||
| 548 | } | ||
| 549 | |||
| 550 | // Map memory for the NRO | ||
| 551 | VAddr map_location{}; | ||
| 552 | const auto map_result{MapNro(&map_location, system.ApplicationProcess(), nro_address, | ||
| 553 | nro_size, bss_address, bss_size, nro_size + bss_size)}; | ||
| 554 | if (map_result != ResultSuccess) { | ||
| 555 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 556 | rb.Push(map_result); | ||
| 557 | } | ||
| 558 | |||
| 559 | // Load the NRO into the mapped memory | ||
| 560 | if (const auto result{ | ||
| 561 | LoadNro(system.ApplicationProcess(), header, nro_address, map_location)}; | ||
| 562 | result.IsError()) { | ||
| 563 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 564 | rb.Push(result); | ||
| 565 | } | ||
| 566 | |||
| 567 | // Track the loaded NRO | ||
| 568 | nro.insert_or_assign(map_location, | ||
| 569 | NROInfo{hash, map_location, nro_size, bss_address, bss_size, | ||
| 570 | header.segment_headers[TEXT_INDEX].memory_size, | ||
| 571 | header.segment_headers[RO_INDEX].memory_size, | ||
| 572 | header.segment_headers[DATA_INDEX].memory_size, nro_address}); | ||
| 573 | |||
| 574 | IPC::ResponseBuilder rb{ctx, 4}; | ||
| 575 | rb.Push(ResultSuccess); | ||
| 576 | rb.Push(map_location); | ||
| 577 | } | ||
| 578 | |||
| 579 | Result UnmapNro(const NROInfo& info) { | ||
| 580 | // Each region must be unmapped separately to validate memory state | ||
| 581 | auto& page_table{system.ApplicationProcess()->GetPageTable()}; | ||
| 582 | |||
| 583 | if (info.bss_size != 0) { | ||
| 584 | R_TRY(page_table.UnmapCodeMemory(info.nro_address + info.text_size + info.ro_size + | ||
| 585 | info.data_size, | ||
| 586 | info.bss_address, info.bss_size)); | ||
| 587 | } | ||
| 588 | |||
| 589 | R_TRY(page_table.UnmapCodeMemory(info.nro_address + info.text_size + info.ro_size, | ||
| 590 | info.src_addr + info.text_size + info.ro_size, | ||
| 591 | info.data_size)); | ||
| 592 | R_TRY(page_table.UnmapCodeMemory(info.nro_address + info.text_size, | ||
| 593 | info.src_addr + info.text_size, info.ro_size)); | ||
| 594 | R_TRY(page_table.UnmapCodeMemory(info.nro_address, info.src_addr, info.text_size)); | ||
| 595 | return ResultSuccess; | ||
| 596 | } | ||
| 597 | |||
| 598 | void UnloadModule(HLERequestContext& ctx) { | ||
| 599 | if (!initialized) { | ||
| 600 | LOG_ERROR(Service_LDR, "LDR:RO not initialized before use!"); | ||
| 601 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 602 | rb.Push(ERROR_NOT_INITIALIZED); | ||
| 603 | return; | ||
| 604 | } | ||
| 605 | |||
| 606 | struct Parameters { | ||
| 607 | u64_le process_id; | ||
| 608 | u64_le nro_address; | ||
| 609 | }; | ||
| 610 | |||
| 611 | IPC::RequestParser rp{ctx}; | ||
| 612 | const auto [process_id, nro_address] = rp.PopRaw<Parameters>(); | ||
| 613 | LOG_DEBUG(Service_LDR, "called with process_id={:016X}, nro_address=0x{:016X}", process_id, | ||
| 614 | nro_address); | ||
| 615 | |||
| 616 | if (!Common::Is4KBAligned(nro_address)) { | ||
| 617 | LOG_ERROR(Service_LDR, "NRO address has invalid alignment (nro_address=0x{:016X})", | ||
| 618 | nro_address); | ||
| 619 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 620 | rb.Push(ERROR_INVALID_ALIGNMENT); | ||
| 621 | return; | ||
| 622 | } | ||
| 623 | |||
| 624 | const auto iter = nro.find(nro_address); | ||
| 625 | if (iter == nro.end()) { | ||
| 626 | LOG_ERROR(Service_LDR, | ||
| 627 | "The NRO attempting to be unmapped was not mapped or has an invalid address " | ||
| 628 | "(nro_address=0x{:016X})!", | ||
| 629 | nro_address); | ||
| 630 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 631 | rb.Push(ERROR_INVALID_NRO_ADDRESS); | ||
| 632 | return; | ||
| 633 | } | ||
| 634 | |||
| 635 | const auto result{UnmapNro(iter->second)}; | ||
| 636 | |||
| 637 | nro.erase(iter); | ||
| 638 | |||
| 639 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 640 | |||
| 641 | rb.Push(result); | ||
| 642 | } | ||
| 643 | |||
| 644 | void Initialize(HLERequestContext& ctx) { | ||
| 645 | LOG_WARNING(Service_LDR, "(STUBBED) called"); | ||
| 646 | |||
| 647 | initialized = true; | ||
| 648 | current_map_addr = | ||
| 649 | GetInteger(system.ApplicationProcess()->GetPageTable().GetAliasCodeRegionStart()); | ||
| 650 | |||
| 651 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 652 | rb.Push(ResultSuccess); | ||
| 653 | } | ||
| 654 | |||
| 655 | private: | ||
| 656 | bool initialized{}; | ||
| 657 | |||
| 658 | std::map<VAddr, NROInfo> nro; | ||
| 659 | std::map<VAddr, std::vector<SHA256Hash>> nrr; | ||
| 660 | VAddr current_map_addr{}; | ||
| 661 | |||
| 662 | bool IsValidNROHash(const SHA256Hash& hash) const { | ||
| 663 | return std::any_of(nrr.begin(), nrr.end(), [&hash](const auto& p) { | ||
| 664 | return std::find(p.second.begin(), p.second.end(), hash) != p.second.end(); | ||
| 665 | }); | ||
| 666 | } | ||
| 667 | |||
| 668 | static bool IsValidNRO(const NROHeader& header, u64 nro_size, u64 bss_size) { | ||
| 669 | return header.magic == Common::MakeMagic('N', 'R', 'O', '0') && | ||
| 670 | header.nro_size == nro_size && header.bss_size == bss_size && | ||
| 671 | |||
| 672 | header.segment_headers[RO_INDEX].memory_offset == | ||
| 673 | header.segment_headers[TEXT_INDEX].memory_offset + | ||
| 674 | header.segment_headers[TEXT_INDEX].memory_size && | ||
| 675 | |||
| 676 | header.segment_headers[DATA_INDEX].memory_offset == | ||
| 677 | header.segment_headers[RO_INDEX].memory_offset + | ||
| 678 | header.segment_headers[RO_INDEX].memory_size && | ||
| 679 | |||
| 680 | nro_size == header.segment_headers[DATA_INDEX].memory_offset + | ||
| 681 | header.segment_headers[DATA_INDEX].memory_size && | ||
| 682 | |||
| 683 | Common::Is4KBAligned(header.segment_headers[TEXT_INDEX].memory_size) && | ||
| 684 | Common::Is4KBAligned(header.segment_headers[RO_INDEX].memory_size) && | ||
| 685 | Common::Is4KBAligned(header.segment_headers[DATA_INDEX].memory_size); | ||
| 686 | } | ||
| 687 | }; | ||
| 688 | |||
| 689 | void LoopProcess(Core::System& system) { | 56 | void LoopProcess(Core::System& system) { |
| 690 | auto server_manager = std::make_unique<ServerManager>(system); | 57 | auto server_manager = std::make_unique<ServerManager>(system); |
| 691 | 58 | ||
| 692 | server_manager->RegisterNamedService("ldr:dmnt", std::make_shared<DebugMonitor>(system)); | 59 | server_manager->RegisterNamedService("ldr:dmnt", std::make_shared<DebugMonitor>(system)); |
| 693 | server_manager->RegisterNamedService("ldr:pm", std::make_shared<ProcessManager>(system)); | 60 | server_manager->RegisterNamedService("ldr:pm", std::make_shared<ProcessManager>(system)); |
| 694 | server_manager->RegisterNamedService("ldr:shel", std::make_shared<Shell>(system)); | 61 | server_manager->RegisterNamedService("ldr:shel", std::make_shared<Shell>(system)); |
| 695 | server_manager->RegisterNamedService("ldr:ro", std::make_shared<RelocatableObject>(system)); | ||
| 696 | 62 | ||
| 697 | ServerManager::RunServer(std::move(server_manager)); | 63 | ServerManager::RunServer(std::move(server_manager)); |
| 698 | } | 64 | } |
diff --git a/src/core/hle/service/ro/ro.cpp b/src/core/hle/service/ro/ro.cpp new file mode 100644 index 000000000..17110d3f1 --- /dev/null +++ b/src/core/hle/service/ro/ro.cpp | |||
| @@ -0,0 +1,709 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include <mbedtls/sha256.h> | ||
| 5 | |||
| 6 | #include "common/scope_exit.h" | ||
| 7 | #include "core/hle/kernel/k_process.h" | ||
| 8 | |||
| 9 | #include "core/hle/service/ipc_helpers.h" | ||
| 10 | #include "core/hle/service/ro/ro.h" | ||
| 11 | #include "core/hle/service/ro/ro_nro_utils.h" | ||
| 12 | #include "core/hle/service/ro/ro_results.h" | ||
| 13 | #include "core/hle/service/ro/ro_types.h" | ||
| 14 | #include "core/hle/service/server_manager.h" | ||
| 15 | #include "core/hle/service/service.h" | ||
| 16 | |||
| 17 | namespace Service::RO { | ||
| 18 | |||
| 19 | namespace { | ||
| 20 | |||
| 21 | // Convenience definitions. | ||
| 22 | constexpr size_t MaxSessions = 0x3; | ||
| 23 | constexpr size_t MaxNrrInfos = 0x40; | ||
| 24 | constexpr size_t MaxNroInfos = 0x40; | ||
| 25 | |||
| 26 | constexpr u64 InvalidProcessId = 0xffffffffffffffffULL; | ||
| 27 | constexpr u64 InvalidContextId = 0xffffffffffffffffULL; | ||
| 28 | |||
| 29 | // Types. | ||
| 30 | using Sha256Hash = std::array<u8, 32>; | ||
| 31 | |||
| 32 | struct NroInfo { | ||
| 33 | u64 base_address; | ||
| 34 | u64 nro_heap_address; | ||
| 35 | u64 nro_heap_size; | ||
| 36 | u64 bss_heap_address; | ||
| 37 | u64 bss_heap_size; | ||
| 38 | u64 code_size; | ||
| 39 | u64 rw_size; | ||
| 40 | ModuleId module_id; | ||
| 41 | }; | ||
| 42 | |||
| 43 | struct NrrInfo { | ||
| 44 | u64 nrr_heap_address; | ||
| 45 | u64 nrr_heap_size; | ||
| 46 | |||
| 47 | // Verification. | ||
| 48 | std::vector<Sha256Hash> hashes; | ||
| 49 | }; | ||
| 50 | |||
| 51 | struct ProcessContext { | ||
| 52 | constexpr ProcessContext() = default; | ||
| 53 | |||
| 54 | void Initialize(Kernel::KProcess* process, u64 process_id) { | ||
| 55 | ASSERT(!m_in_use); | ||
| 56 | |||
| 57 | m_nro_in_use = {}; | ||
| 58 | m_nrr_in_use = {}; | ||
| 59 | m_nro_infos = {}; | ||
| 60 | m_nrr_infos = {}; | ||
| 61 | |||
| 62 | m_process = process; | ||
| 63 | m_process_id = process_id; | ||
| 64 | m_in_use = true; | ||
| 65 | |||
| 66 | if (m_process) { | ||
| 67 | m_process->Open(); | ||
| 68 | } | ||
| 69 | } | ||
| 70 | |||
| 71 | void Finalize() { | ||
| 72 | ASSERT(m_in_use); | ||
| 73 | |||
| 74 | if (m_process) { | ||
| 75 | m_process->Close(); | ||
| 76 | } | ||
| 77 | |||
| 78 | m_nro_in_use = {}; | ||
| 79 | m_nrr_in_use = {}; | ||
| 80 | m_nro_infos = {}; | ||
| 81 | m_nrr_infos = {}; | ||
| 82 | |||
| 83 | m_process = nullptr; | ||
| 84 | m_process_id = InvalidProcessId; | ||
| 85 | m_in_use = false; | ||
| 86 | } | ||
| 87 | |||
| 88 | Kernel::KProcess* GetProcess() const { | ||
| 89 | return m_process; | ||
| 90 | } | ||
| 91 | |||
| 92 | u64 GetProcessId() const { | ||
| 93 | return m_process_id; | ||
| 94 | } | ||
| 95 | |||
| 96 | bool IsFree() const { | ||
| 97 | return !m_in_use; | ||
| 98 | } | ||
| 99 | |||
| 100 | u64 GetProgramId(Kernel::KProcess* other_process) const { | ||
| 101 | // Automatically select a handle, allowing for override. | ||
| 102 | if (other_process) { | ||
| 103 | return other_process->GetProgramId(); | ||
| 104 | } else if (m_process) { | ||
| 105 | return m_process->GetProgramId(); | ||
| 106 | } else { | ||
| 107 | return 0; | ||
| 108 | } | ||
| 109 | } | ||
| 110 | |||
| 111 | Result GetNrrInfoByAddress(NrrInfo** out, u64 nrr_heap_address) { | ||
| 112 | for (size_t i = 0; i < MaxNrrInfos; i++) { | ||
| 113 | if (m_nrr_in_use[i] && m_nrr_infos[i].nrr_heap_address == nrr_heap_address) { | ||
| 114 | if (out != nullptr) { | ||
| 115 | *out = std::addressof(m_nrr_infos[i]); | ||
| 116 | } | ||
| 117 | R_SUCCEED(); | ||
| 118 | } | ||
| 119 | } | ||
| 120 | R_THROW(RO::ResultNotRegistered); | ||
| 121 | } | ||
| 122 | |||
| 123 | Result GetFreeNrrInfo(NrrInfo** out) { | ||
| 124 | for (size_t i = 0; i < MaxNrrInfos; i++) { | ||
| 125 | if (!m_nrr_in_use[i]) { | ||
| 126 | if (out != nullptr) { | ||
| 127 | *out = std::addressof(m_nrr_infos[i]); | ||
| 128 | } | ||
| 129 | R_SUCCEED(); | ||
| 130 | } | ||
| 131 | } | ||
| 132 | R_THROW(RO::ResultTooManyNrr); | ||
| 133 | } | ||
| 134 | |||
| 135 | Result GetNroInfoByAddress(NroInfo** out, u64 nro_address) { | ||
| 136 | for (size_t i = 0; i < MaxNroInfos; i++) { | ||
| 137 | if (m_nro_in_use[i] && m_nro_infos[i].base_address == nro_address) { | ||
| 138 | if (out != nullptr) { | ||
| 139 | *out = std::addressof(m_nro_infos[i]); | ||
| 140 | } | ||
| 141 | R_SUCCEED(); | ||
| 142 | } | ||
| 143 | } | ||
| 144 | R_THROW(RO::ResultNotLoaded); | ||
| 145 | } | ||
| 146 | |||
| 147 | Result GetNroInfoByModuleId(NroInfo** out, const ModuleId* module_id) { | ||
| 148 | for (size_t i = 0; i < MaxNroInfos; i++) { | ||
| 149 | if (m_nro_in_use[i] && std::memcmp(std::addressof(m_nro_infos[i].module_id), module_id, | ||
| 150 | sizeof(*module_id)) == 0) { | ||
| 151 | if (out != nullptr) { | ||
| 152 | *out = std::addressof(m_nro_infos[i]); | ||
| 153 | } | ||
| 154 | R_SUCCEED(); | ||
| 155 | } | ||
| 156 | } | ||
| 157 | R_THROW(RO::ResultNotLoaded); | ||
| 158 | } | ||
| 159 | |||
| 160 | Result GetFreeNroInfo(NroInfo** out) { | ||
| 161 | for (size_t i = 0; i < MaxNroInfos; i++) { | ||
| 162 | if (!m_nro_in_use[i]) { | ||
| 163 | if (out != nullptr) { | ||
| 164 | *out = std::addressof(m_nro_infos[i]); | ||
| 165 | } | ||
| 166 | R_SUCCEED(); | ||
| 167 | } | ||
| 168 | } | ||
| 169 | R_THROW(RO::ResultTooManyNro); | ||
| 170 | } | ||
| 171 | |||
| 172 | Result ValidateHasNroHash(u64 base_address, const NroHeader* nro_header) const { | ||
| 173 | // Calculate hash. | ||
| 174 | Sha256Hash hash; | ||
| 175 | { | ||
| 176 | const u64 size = nro_header->GetSize(); | ||
| 177 | |||
| 178 | std::vector<u8> nro_data(size); | ||
| 179 | m_process->GetMemory().ReadBlock(base_address, nro_data.data(), size); | ||
| 180 | |||
| 181 | mbedtls_sha256_ret(nro_data.data(), size, hash.data(), 0); | ||
| 182 | } | ||
| 183 | |||
| 184 | for (size_t i = 0; i < MaxNrrInfos; i++) { | ||
| 185 | // Ensure we only check NRRs that are used. | ||
| 186 | if (!m_nrr_in_use[i]) { | ||
| 187 | continue; | ||
| 188 | } | ||
| 189 | |||
| 190 | // Locate the hash within the hash list. | ||
| 191 | const auto hash_it = std::ranges::find(m_nrr_infos[i].hashes, hash); | ||
| 192 | if (hash_it == m_nrr_infos[i].hashes.end()) { | ||
| 193 | continue; | ||
| 194 | } | ||
| 195 | |||
| 196 | // The hash is valid! | ||
| 197 | R_SUCCEED(); | ||
| 198 | } | ||
| 199 | |||
| 200 | R_THROW(RO::ResultNotAuthorized); | ||
| 201 | } | ||
| 202 | |||
| 203 | Result ValidateNro(ModuleId* out_module_id, u64* out_rx_size, u64* out_ro_size, | ||
| 204 | u64* out_rw_size, u64 base_address, u64 expected_nro_size, | ||
| 205 | u64 expected_bss_size) { | ||
| 206 | // Ensure we have a process to work on. | ||
| 207 | R_UNLESS(m_process != nullptr, RO::ResultInvalidProcess); | ||
| 208 | |||
| 209 | // Read the NRO header. | ||
| 210 | NroHeader header{}; | ||
| 211 | m_process->GetMemory().ReadBlock(base_address, std::addressof(header), sizeof(header)); | ||
| 212 | |||
| 213 | // Validate header. | ||
| 214 | R_UNLESS(header.IsMagicValid(), RO::ResultInvalidNro); | ||
| 215 | |||
| 216 | // Read sizes from header. | ||
| 217 | const u64 nro_size = header.GetSize(); | ||
| 218 | const u64 text_ofs = header.GetTextOffset(); | ||
| 219 | const u64 text_size = header.GetTextSize(); | ||
| 220 | const u64 ro_ofs = header.GetRoOffset(); | ||
| 221 | const u64 ro_size = header.GetRoSize(); | ||
| 222 | const u64 rw_ofs = header.GetRwOffset(); | ||
| 223 | const u64 rw_size = header.GetRwSize(); | ||
| 224 | const u64 bss_size = header.GetBssSize(); | ||
| 225 | |||
| 226 | // Validate sizes meet expected. | ||
| 227 | R_UNLESS(nro_size == expected_nro_size, RO::ResultInvalidNro); | ||
| 228 | R_UNLESS(bss_size == expected_bss_size, RO::ResultInvalidNro); | ||
| 229 | |||
| 230 | // Validate all sizes are aligned. | ||
| 231 | R_UNLESS(Common::IsAligned(text_size, Core::Memory::YUZU_PAGESIZE), RO::ResultInvalidNro); | ||
| 232 | R_UNLESS(Common::IsAligned(ro_size, Core::Memory::YUZU_PAGESIZE), RO::ResultInvalidNro); | ||
| 233 | R_UNLESS(Common::IsAligned(rw_size, Core::Memory::YUZU_PAGESIZE), RO::ResultInvalidNro); | ||
| 234 | R_UNLESS(Common::IsAligned(bss_size, Core::Memory::YUZU_PAGESIZE), RO::ResultInvalidNro); | ||
| 235 | |||
| 236 | // Validate sections are in order. | ||
| 237 | R_UNLESS(text_ofs <= ro_ofs, RO::ResultInvalidNro); | ||
| 238 | R_UNLESS(ro_ofs <= rw_ofs, RO::ResultInvalidNro); | ||
| 239 | |||
| 240 | // Validate sections are sequential and contiguous. | ||
| 241 | R_UNLESS(text_ofs == 0, RO::ResultInvalidNro); | ||
| 242 | R_UNLESS(text_ofs + text_size == ro_ofs, RO::ResultInvalidNro); | ||
| 243 | R_UNLESS(ro_ofs + ro_size == rw_ofs, RO::ResultInvalidNro); | ||
| 244 | R_UNLESS(rw_ofs + rw_size == nro_size, RO::ResultInvalidNro); | ||
| 245 | |||
| 246 | // Verify NRO hash. | ||
| 247 | R_TRY(this->ValidateHasNroHash(base_address, std::addressof(header))); | ||
| 248 | |||
| 249 | // Check if NRO has already been loaded. | ||
| 250 | const ModuleId* module_id = header.GetModuleId(); | ||
| 251 | R_UNLESS(R_FAILED(this->GetNroInfoByModuleId(nullptr, module_id)), RO::ResultAlreadyLoaded); | ||
| 252 | |||
| 253 | // Apply patches to NRO. | ||
| 254 | // LocateAndApplyIpsPatchesToModule(module_id, static_cast<u8*>(mapped_memory), nro_size); | ||
| 255 | |||
| 256 | // Copy to output. | ||
| 257 | *out_module_id = *module_id; | ||
| 258 | *out_rx_size = text_size; | ||
| 259 | *out_ro_size = ro_size; | ||
| 260 | *out_rw_size = rw_size; | ||
| 261 | R_SUCCEED(); | ||
| 262 | } | ||
| 263 | |||
| 264 | void SetNrrInfoInUse(const NrrInfo* info, bool in_use) { | ||
| 265 | ASSERT(std::addressof(m_nrr_infos[0]) <= info && | ||
| 266 | info <= std::addressof(m_nrr_infos[MaxNrrInfos - 1])); | ||
| 267 | const size_t index = info - std::addressof(m_nrr_infos[0]); | ||
| 268 | m_nrr_in_use[index] = in_use; | ||
| 269 | } | ||
| 270 | |||
| 271 | void SetNroInfoInUse(const NroInfo* info, bool in_use) { | ||
| 272 | ASSERT(std::addressof(m_nro_infos[0]) <= info && | ||
| 273 | info <= std::addressof(m_nro_infos[MaxNroInfos - 1])); | ||
| 274 | const size_t index = info - std::addressof(m_nro_infos[0]); | ||
| 275 | m_nro_in_use[index] = in_use; | ||
| 276 | } | ||
| 277 | |||
| 278 | private: | ||
| 279 | std::array<bool, MaxNroInfos> m_nro_in_use{}; | ||
| 280 | std::array<bool, MaxNrrInfos> m_nrr_in_use{}; | ||
| 281 | std::array<NroInfo, MaxNroInfos> m_nro_infos{}; | ||
| 282 | std::array<NrrInfo, MaxNrrInfos> m_nrr_infos{}; | ||
| 283 | Kernel::KProcess* m_process{}; | ||
| 284 | u64 m_process_id{InvalidProcessId}; | ||
| 285 | bool m_in_use{}; | ||
| 286 | }; | ||
| 287 | |||
| 288 | Result ValidateAddressAndNonZeroSize(u64 address, u64 size) { | ||
| 289 | R_UNLESS(Common::IsAligned(address, Core::Memory::YUZU_PAGESIZE), RO::ResultInvalidAddress); | ||
| 290 | R_UNLESS(size != 0, RO::ResultInvalidSize); | ||
| 291 | R_UNLESS(Common::IsAligned(size, Core::Memory::YUZU_PAGESIZE), RO::ResultInvalidSize); | ||
| 292 | R_UNLESS(address < address + size, RO::ResultInvalidSize); | ||
| 293 | R_SUCCEED(); | ||
| 294 | } | ||
| 295 | |||
| 296 | Result ValidateAddressAndSize(u64 address, u64 size) { | ||
| 297 | R_UNLESS(Common::IsAligned(address, Core::Memory::YUZU_PAGESIZE), RO::ResultInvalidAddress); | ||
| 298 | R_UNLESS(Common::IsAligned(size, Core::Memory::YUZU_PAGESIZE), RO::ResultInvalidSize); | ||
| 299 | R_UNLESS(size == 0 || address < address + size, RO::ResultInvalidSize); | ||
| 300 | R_SUCCEED(); | ||
| 301 | } | ||
| 302 | |||
| 303 | class RoContext { | ||
| 304 | public: | ||
| 305 | explicit RoContext() = default; | ||
| 306 | |||
| 307 | Result RegisterProcess(size_t* out_context_id, Kernel::KProcess* process, u64 process_id) { | ||
| 308 | // Validate process id. | ||
| 309 | R_UNLESS(process->GetProcessId() == process_id, RO::ResultInvalidProcess); | ||
| 310 | |||
| 311 | // Check if a process context already exists. | ||
| 312 | R_UNLESS(this->GetContextByProcessId(process_id) == nullptr, RO::ResultInvalidSession); | ||
| 313 | |||
| 314 | // Allocate a context to manage the process handle. | ||
| 315 | *out_context_id = this->AllocateContext(process, process_id); | ||
| 316 | |||
| 317 | R_SUCCEED(); | ||
| 318 | } | ||
| 319 | |||
| 320 | Result ValidateProcess(size_t context_id, u64 process_id) { | ||
| 321 | const ProcessContext* ctx = this->GetContextById(context_id); | ||
| 322 | R_UNLESS(ctx != nullptr, RO::ResultInvalidProcess); | ||
| 323 | R_UNLESS(ctx->GetProcessId() == process_id, RO::ResultInvalidProcess); | ||
| 324 | R_SUCCEED(); | ||
| 325 | } | ||
| 326 | |||
| 327 | void UnregisterProcess(size_t context_id) { | ||
| 328 | this->FreeContext(context_id); | ||
| 329 | } | ||
| 330 | |||
| 331 | Result RegisterModuleInfo(size_t context_id, u64 nrr_address, u64 nrr_size, NrrKind nrr_kind, | ||
| 332 | bool enforce_nrr_kind) { | ||
| 333 | // Get context. | ||
| 334 | ProcessContext* context = this->GetContextById(context_id); | ||
| 335 | ASSERT(context != nullptr); | ||
| 336 | |||
| 337 | // Validate address/size. | ||
| 338 | R_TRY(ValidateAddressAndNonZeroSize(nrr_address, nrr_size)); | ||
| 339 | |||
| 340 | // Check we have space for a new NRR. | ||
| 341 | NrrInfo* nrr_info = nullptr; | ||
| 342 | R_TRY(context->GetFreeNrrInfo(std::addressof(nrr_info))); | ||
| 343 | |||
| 344 | // Ensure we have a valid process to read from. | ||
| 345 | Kernel::KProcess* process = context->GetProcess(); | ||
| 346 | R_UNLESS(process != nullptr, RO::ResultInvalidProcess); | ||
| 347 | |||
| 348 | // Read NRR. | ||
| 349 | NrrHeader header{}; | ||
| 350 | process->GetMemory().ReadBlock(nrr_address, std::addressof(header), sizeof(header)); | ||
| 351 | |||
| 352 | // Set NRR info. | ||
| 353 | context->SetNrrInfoInUse(nrr_info, true); | ||
| 354 | nrr_info->nrr_heap_address = nrr_address; | ||
| 355 | nrr_info->nrr_heap_size = nrr_size; | ||
| 356 | |||
| 357 | // Read NRR hash list. | ||
| 358 | nrr_info->hashes.resize(header.GetNumHashes()); | ||
| 359 | process->GetMemory().ReadBlock(nrr_address + header.GetHashesOffset(), | ||
| 360 | nrr_info->hashes.data(), | ||
| 361 | sizeof(Sha256Hash) * header.GetNumHashes()); | ||
| 362 | |||
| 363 | R_SUCCEED(); | ||
| 364 | } | ||
| 365 | |||
| 366 | Result UnregisterModuleInfo(size_t context_id, u64 nrr_address) { | ||
| 367 | // Get context. | ||
| 368 | ProcessContext* context = this->GetContextById(context_id); | ||
| 369 | ASSERT(context != nullptr); | ||
| 370 | |||
| 371 | // Validate address. | ||
| 372 | R_UNLESS(Common::IsAligned(nrr_address, Core::Memory::YUZU_PAGESIZE), | ||
| 373 | RO::ResultInvalidAddress); | ||
| 374 | |||
| 375 | // Check the NRR is loaded. | ||
| 376 | NrrInfo* nrr_info = nullptr; | ||
| 377 | R_TRY(context->GetNrrInfoByAddress(std::addressof(nrr_info), nrr_address)); | ||
| 378 | |||
| 379 | // Nintendo does this unconditionally, whether or not the actual unmap succeeds. | ||
| 380 | context->SetNrrInfoInUse(nrr_info, false); | ||
| 381 | *nrr_info = {}; | ||
| 382 | |||
| 383 | R_SUCCEED(); | ||
| 384 | } | ||
| 385 | |||
| 386 | Result MapManualLoadModuleMemory(u64* out_address, size_t context_id, u64 nro_address, | ||
| 387 | u64 nro_size, u64 bss_address, u64 bss_size) { | ||
| 388 | // Get context. | ||
| 389 | ProcessContext* context = this->GetContextById(context_id); | ||
| 390 | ASSERT(context != nullptr); | ||
| 391 | |||
| 392 | // Validate address/size. | ||
| 393 | R_TRY(ValidateAddressAndNonZeroSize(nro_address, nro_size)); | ||
| 394 | R_TRY(ValidateAddressAndSize(bss_address, bss_size)); | ||
| 395 | |||
| 396 | const u64 total_size = nro_size + bss_size; | ||
| 397 | R_UNLESS(total_size >= nro_size, RO::ResultInvalidSize); | ||
| 398 | R_UNLESS(total_size >= bss_size, RO::ResultInvalidSize); | ||
| 399 | |||
| 400 | // Check we have space for a new NRO. | ||
| 401 | NroInfo* nro_info = nullptr; | ||
| 402 | R_TRY(context->GetFreeNroInfo(std::addressof(nro_info))); | ||
| 403 | nro_info->nro_heap_address = nro_address; | ||
| 404 | nro_info->nro_heap_size = nro_size; | ||
| 405 | nro_info->bss_heap_address = bss_address; | ||
| 406 | nro_info->bss_heap_size = bss_size; | ||
| 407 | |||
| 408 | // Map the NRO. | ||
| 409 | R_TRY(MapNro(std::addressof(nro_info->base_address), context->GetProcess(), nro_address, | ||
| 410 | nro_size, bss_address, bss_size, generate_random)); | ||
| 411 | ON_RESULT_FAILURE { | ||
| 412 | UnmapNro(context->GetProcess(), nro_info->base_address, nro_address, nro_size, | ||
| 413 | bss_address, bss_size); | ||
| 414 | }; | ||
| 415 | |||
| 416 | // Validate the NRO (parsing region extents). | ||
| 417 | u64 rx_size = 0, ro_size = 0, rw_size = 0; | ||
| 418 | R_TRY(context->ValidateNro(std::addressof(nro_info->module_id), std::addressof(rx_size), | ||
| 419 | std::addressof(ro_size), std::addressof(rw_size), | ||
| 420 | nro_info->base_address, nro_size, bss_size)); | ||
| 421 | |||
| 422 | // Set NRO perms. | ||
| 423 | R_TRY(SetNroPerms(context->GetProcess(), nro_info->base_address, rx_size, ro_size, | ||
| 424 | rw_size + bss_size)); | ||
| 425 | |||
| 426 | context->SetNroInfoInUse(nro_info, true); | ||
| 427 | nro_info->code_size = rx_size + ro_size; | ||
| 428 | nro_info->rw_size = rw_size; | ||
| 429 | *out_address = nro_info->base_address; | ||
| 430 | R_SUCCEED(); | ||
| 431 | } | ||
| 432 | |||
| 433 | Result UnmapManualLoadModuleMemory(size_t context_id, u64 nro_address) { | ||
| 434 | // Get context. | ||
| 435 | ProcessContext* context = this->GetContextById(context_id); | ||
| 436 | ASSERT(context != nullptr); | ||
| 437 | |||
| 438 | // Validate address. | ||
| 439 | R_UNLESS(Common::IsAligned(nro_address, Core::Memory::YUZU_PAGESIZE), | ||
| 440 | RO::ResultInvalidAddress); | ||
| 441 | |||
| 442 | // Check the NRO is loaded. | ||
| 443 | NroInfo* nro_info = nullptr; | ||
| 444 | R_TRY(context->GetNroInfoByAddress(std::addressof(nro_info), nro_address)); | ||
| 445 | |||
| 446 | // Unmap. | ||
| 447 | const NroInfo nro_backup = *nro_info; | ||
| 448 | { | ||
| 449 | // Nintendo does this unconditionally, whether or not the actual unmap succeeds. | ||
| 450 | context->SetNroInfoInUse(nro_info, false); | ||
| 451 | std::memset(nro_info, 0, sizeof(*nro_info)); | ||
| 452 | } | ||
| 453 | R_RETURN(UnmapNro(context->GetProcess(), nro_backup.base_address, | ||
| 454 | nro_backup.nro_heap_address, nro_backup.code_size + nro_backup.rw_size, | ||
| 455 | nro_backup.bss_heap_address, nro_backup.bss_heap_size)); | ||
| 456 | } | ||
| 457 | |||
| 458 | private: | ||
| 459 | std::array<ProcessContext, MaxSessions> process_contexts; | ||
| 460 | std::mt19937_64 generate_random; | ||
| 461 | |||
| 462 | // Context Helpers. | ||
| 463 | ProcessContext* GetContextById(size_t context_id) { | ||
| 464 | if (context_id == InvalidContextId) { | ||
| 465 | return nullptr; | ||
| 466 | } | ||
| 467 | |||
| 468 | ASSERT(context_id < process_contexts.size()); | ||
| 469 | return std::addressof(process_contexts[context_id]); | ||
| 470 | } | ||
| 471 | |||
| 472 | ProcessContext* GetContextByProcessId(u64 process_id) { | ||
| 473 | for (size_t i = 0; i < MaxSessions; i++) { | ||
| 474 | if (process_contexts[i].GetProcessId() == process_id) { | ||
| 475 | return std::addressof(process_contexts[i]); | ||
| 476 | } | ||
| 477 | } | ||
| 478 | return nullptr; | ||
| 479 | } | ||
| 480 | |||
| 481 | size_t AllocateContext(Kernel::KProcess* process, u64 process_id) { | ||
| 482 | // Find a free process context. | ||
| 483 | for (size_t i = 0; i < MaxSessions; i++) { | ||
| 484 | ProcessContext* context = std::addressof(process_contexts[i]); | ||
| 485 | |||
| 486 | if (context->IsFree()) { | ||
| 487 | context->Initialize(process, process_id); | ||
| 488 | return i; | ||
| 489 | } | ||
| 490 | } | ||
| 491 | |||
| 492 | // Failure to find a free context is actually an abort condition. | ||
| 493 | UNREACHABLE(); | ||
| 494 | } | ||
| 495 | |||
| 496 | void FreeContext(size_t context_id) { | ||
| 497 | if (ProcessContext* context = GetContextById(context_id); context != nullptr) { | ||
| 498 | context->Finalize(); | ||
| 499 | } | ||
| 500 | } | ||
| 501 | }; | ||
| 502 | |||
| 503 | class RoInterface { | ||
| 504 | public: | ||
| 505 | explicit RoInterface(std::shared_ptr<RoContext> ro, NrrKind nrr_kind) | ||
| 506 | : m_ro(ro), m_context_id(InvalidContextId), m_nrr_kind(nrr_kind) {} | ||
| 507 | ~RoInterface() { | ||
| 508 | m_ro->UnregisterProcess(m_context_id); | ||
| 509 | } | ||
| 510 | |||
| 511 | Result MapManualLoadModuleMemory(u64* out_load_address, u64 client_pid, u64 nro_address, | ||
| 512 | u64 nro_size, u64 bss_address, u64 bss_size) { | ||
| 513 | R_TRY(m_ro->ValidateProcess(m_context_id, client_pid)); | ||
| 514 | R_RETURN(m_ro->MapManualLoadModuleMemory(out_load_address, m_context_id, nro_address, | ||
| 515 | nro_size, bss_address, bss_size)); | ||
| 516 | } | ||
| 517 | |||
| 518 | Result UnmapManualLoadModuleMemory(u64 client_pid, u64 nro_address) { | ||
| 519 | R_TRY(m_ro->ValidateProcess(m_context_id, client_pid)); | ||
| 520 | R_RETURN(m_ro->UnmapManualLoadModuleMemory(m_context_id, nro_address)); | ||
| 521 | } | ||
| 522 | |||
| 523 | Result RegisterModuleInfo(u64 client_pid, u64 nrr_address, u64 nrr_size) { | ||
| 524 | R_TRY(m_ro->ValidateProcess(m_context_id, client_pid)); | ||
| 525 | R_RETURN( | ||
| 526 | m_ro->RegisterModuleInfo(m_context_id, nrr_address, nrr_size, NrrKind::User, true)); | ||
| 527 | } | ||
| 528 | |||
| 529 | Result UnregisterModuleInfo(u64 client_pid, u64 nrr_address) { | ||
| 530 | R_TRY(m_ro->ValidateProcess(m_context_id, client_pid)); | ||
| 531 | R_RETURN(m_ro->UnregisterModuleInfo(m_context_id, nrr_address)); | ||
| 532 | } | ||
| 533 | |||
| 534 | Result RegisterProcessHandle(u64 client_pid, Kernel::KProcess* process) { | ||
| 535 | // Register the process. | ||
| 536 | R_RETURN(m_ro->RegisterProcess(std::addressof(m_context_id), process, client_pid)); | ||
| 537 | } | ||
| 538 | |||
| 539 | Result RegisterProcessModuleInfo(u64 client_pid, u64 nrr_address, u64 nrr_size, | ||
| 540 | Kernel::KProcess* process) { | ||
| 541 | // Validate the process. | ||
| 542 | R_TRY(m_ro->ValidateProcess(m_context_id, client_pid)); | ||
| 543 | |||
| 544 | // Register the module. | ||
| 545 | R_RETURN(m_ro->RegisterModuleInfo(m_context_id, nrr_address, nrr_size, m_nrr_kind, | ||
| 546 | m_nrr_kind == NrrKind::JitPlugin)); | ||
| 547 | } | ||
| 548 | |||
| 549 | private: | ||
| 550 | std::shared_ptr<RoContext> m_ro{}; | ||
| 551 | size_t m_context_id{}; | ||
| 552 | NrrKind m_nrr_kind{}; | ||
| 553 | }; | ||
| 554 | |||
| 555 | class IRoInterface : public ServiceFramework<IRoInterface> { | ||
| 556 | public: | ||
| 557 | explicit IRoInterface(Core::System& system_, const char* name_, std::shared_ptr<RoContext> ro, | ||
| 558 | NrrKind nrr_kind) | ||
| 559 | : ServiceFramework{system_, name_}, interface { | ||
| 560 | ro, nrr_kind | ||
| 561 | } { | ||
| 562 | // clang-format off | ||
| 563 | static const FunctionInfo functions[] = { | ||
| 564 | {0, &IRoInterface::MapManualLoadModuleMemory, "MapManualLoadModuleMemory"}, | ||
| 565 | {1, &IRoInterface::UnmapManualLoadModuleMemory, "UnmapManualLoadModuleMemory"}, | ||
| 566 | {2, &IRoInterface::RegisterModuleInfo, "RegisterModuleInfo"}, | ||
| 567 | {3, &IRoInterface::UnregisterModuleInfo, "UnregisterModuleInfo"}, | ||
| 568 | {4, &IRoInterface::RegisterProcessHandle, "RegisterProcessHandle"}, | ||
| 569 | {10, &IRoInterface::RegisterProcessModuleInfo, "RegisterProcessModuleInfo"}, | ||
| 570 | }; | ||
| 571 | // clang-format on | ||
| 572 | |||
| 573 | RegisterHandlers(functions); | ||
| 574 | } | ||
| 575 | |||
| 576 | private: | ||
| 577 | void MapManualLoadModuleMemory(HLERequestContext& ctx) { | ||
| 578 | LOG_DEBUG(Service_LDR, "(called)"); | ||
| 579 | |||
| 580 | struct InputParameters { | ||
| 581 | u64 client_pid; | ||
| 582 | u64 nro_address; | ||
| 583 | u64 nro_size; | ||
| 584 | u64 bss_address; | ||
| 585 | u64 bss_size; | ||
| 586 | }; | ||
| 587 | |||
| 588 | IPC::RequestParser rp{ctx}; | ||
| 589 | auto params = rp.PopRaw<InputParameters>(); | ||
| 590 | |||
| 591 | u64 load_address = 0; | ||
| 592 | auto result = interface.MapManualLoadModuleMemory(&load_address, ctx.GetPID(), | ||
| 593 | params.nro_address, params.nro_size, | ||
| 594 | params.bss_address, params.bss_size); | ||
| 595 | |||
| 596 | IPC::ResponseBuilder rb{ctx, 4}; | ||
| 597 | rb.Push(result); | ||
| 598 | rb.Push(load_address); | ||
| 599 | } | ||
| 600 | |||
| 601 | void UnmapManualLoadModuleMemory(HLERequestContext& ctx) { | ||
| 602 | LOG_DEBUG(Service_LDR, "(called)"); | ||
| 603 | |||
| 604 | struct InputParameters { | ||
| 605 | u64 client_pid; | ||
| 606 | u64 nro_address; | ||
| 607 | }; | ||
| 608 | |||
| 609 | IPC::RequestParser rp{ctx}; | ||
| 610 | auto params = rp.PopRaw<InputParameters>(); | ||
| 611 | auto result = interface.UnmapManualLoadModuleMemory(ctx.GetPID(), params.nro_address); | ||
| 612 | |||
| 613 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 614 | rb.Push(result); | ||
| 615 | } | ||
| 616 | |||
| 617 | void RegisterModuleInfo(HLERequestContext& ctx) { | ||
| 618 | LOG_DEBUG(Service_LDR, "(called)"); | ||
| 619 | |||
| 620 | struct InputParameters { | ||
| 621 | u64 client_pid; | ||
| 622 | u64 nrr_address; | ||
| 623 | u64 nrr_size; | ||
| 624 | }; | ||
| 625 | |||
| 626 | IPC::RequestParser rp{ctx}; | ||
| 627 | auto params = rp.PopRaw<InputParameters>(); | ||
| 628 | auto result = | ||
| 629 | interface.RegisterModuleInfo(ctx.GetPID(), params.nrr_address, params.nrr_size); | ||
| 630 | |||
| 631 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 632 | rb.Push(result); | ||
| 633 | } | ||
| 634 | |||
| 635 | void UnregisterModuleInfo(HLERequestContext& ctx) { | ||
| 636 | LOG_DEBUG(Service_LDR, "(called)"); | ||
| 637 | |||
| 638 | struct InputParameters { | ||
| 639 | u64 client_pid; | ||
| 640 | u64 nrr_address; | ||
| 641 | }; | ||
| 642 | |||
| 643 | IPC::RequestParser rp{ctx}; | ||
| 644 | auto params = rp.PopRaw<InputParameters>(); | ||
| 645 | auto result = interface.UnregisterModuleInfo(ctx.GetPID(), params.nrr_address); | ||
| 646 | |||
| 647 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 648 | rb.Push(result); | ||
| 649 | } | ||
| 650 | |||
| 651 | void RegisterProcessHandle(HLERequestContext& ctx) { | ||
| 652 | LOG_DEBUG(Service_LDR, "(called)"); | ||
| 653 | |||
| 654 | auto process_h = ctx.GetClientHandleTable().GetObject(ctx.GetCopyHandle(0)); | ||
| 655 | auto client_pid = ctx.GetPID(); | ||
| 656 | auto result = interface.RegisterProcessHandle(client_pid, | ||
| 657 | process_h->DynamicCast<Kernel::KProcess*>()); | ||
| 658 | |||
| 659 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 660 | rb.Push(result); | ||
| 661 | } | ||
| 662 | |||
| 663 | void RegisterProcessModuleInfo(HLERequestContext& ctx) { | ||
| 664 | LOG_DEBUG(Service_LDR, "(called)"); | ||
| 665 | |||
| 666 | struct InputParameters { | ||
| 667 | u64 client_pid; | ||
| 668 | u64 nrr_address; | ||
| 669 | u64 nrr_size; | ||
| 670 | }; | ||
| 671 | |||
| 672 | IPC::RequestParser rp{ctx}; | ||
| 673 | auto params = rp.PopRaw<InputParameters>(); | ||
| 674 | auto process_h = ctx.GetClientHandleTable().GetObject(ctx.GetCopyHandle(0)); | ||
| 675 | |||
| 676 | auto client_pid = ctx.GetPID(); | ||
| 677 | auto result = | ||
| 678 | interface.RegisterProcessModuleInfo(client_pid, params.nrr_address, params.nrr_size, | ||
| 679 | process_h->DynamicCast<Kernel::KProcess*>()); | ||
| 680 | |||
| 681 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 682 | rb.Push(result); | ||
| 683 | } | ||
| 684 | |||
| 685 | RoInterface interface; | ||
| 686 | }; | ||
| 687 | |||
| 688 | } // namespace | ||
| 689 | |||
| 690 | void LoopProcess(Core::System& system) { | ||
| 691 | auto server_manager = std::make_unique<ServerManager>(system); | ||
| 692 | |||
| 693 | auto ro = std::make_shared<RoContext>(); | ||
| 694 | |||
| 695 | const auto RoInterfaceFactoryForUser = [&, ro] { | ||
| 696 | return std::make_shared<IRoInterface>(system, "ldr:ro", ro, NrrKind::User); | ||
| 697 | }; | ||
| 698 | |||
| 699 | const auto RoInterfaceFactoryForJitPlugin = [&, ro] { | ||
| 700 | return std::make_shared<IRoInterface>(system, "ro:1", ro, NrrKind::JitPlugin); | ||
| 701 | }; | ||
| 702 | |||
| 703 | server_manager->RegisterNamedService("ldr:ro", std::move(RoInterfaceFactoryForUser)); | ||
| 704 | server_manager->RegisterNamedService("ro:1", std::move(RoInterfaceFactoryForJitPlugin)); | ||
| 705 | |||
| 706 | ServerManager::RunServer(std::move(server_manager)); | ||
| 707 | } | ||
| 708 | |||
| 709 | } // namespace Service::RO | ||
diff --git a/src/core/hle/service/ro/ro.h b/src/core/hle/service/ro/ro.h new file mode 100644 index 000000000..74dc08536 --- /dev/null +++ b/src/core/hle/service/ro/ro.h | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | namespace Core { | ||
| 7 | class System; | ||
| 8 | } | ||
| 9 | |||
| 10 | namespace Service::RO { | ||
| 11 | |||
| 12 | void LoopProcess(Core::System& system); | ||
| 13 | |||
| 14 | } // namespace Service::RO | ||
diff --git a/src/core/hle/service/ro/ro_nro_utils.cpp b/src/core/hle/service/ro/ro_nro_utils.cpp new file mode 100644 index 000000000..268c7f93e --- /dev/null +++ b/src/core/hle/service/ro/ro_nro_utils.cpp | |||
| @@ -0,0 +1,185 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "core/hle/kernel/k_process.h" | ||
| 5 | #include "core/hle/service/ro/ro_nro_utils.h" | ||
| 6 | #include "core/hle/service/ro/ro_results.h" | ||
| 7 | |||
| 8 | namespace Service::RO { | ||
| 9 | |||
| 10 | namespace { | ||
| 11 | |||
| 12 | struct ProcessMemoryRegion { | ||
| 13 | u64 address; | ||
| 14 | u64 size; | ||
| 15 | }; | ||
| 16 | |||
| 17 | size_t GetTotalProcessMemoryRegionSize(const ProcessMemoryRegion* regions, size_t num_regions) { | ||
| 18 | size_t total = 0; | ||
| 19 | |||
| 20 | for (size_t i = 0; i < num_regions; ++i) { | ||
| 21 | total += regions[i].size; | ||
| 22 | } | ||
| 23 | |||
| 24 | return total; | ||
| 25 | } | ||
| 26 | |||
| 27 | size_t SetupNroProcessMemoryRegions(ProcessMemoryRegion* regions, u64 nro_heap_address, | ||
| 28 | u64 nro_heap_size, u64 bss_heap_address, u64 bss_heap_size) { | ||
| 29 | // Reset region count. | ||
| 30 | size_t num_regions = 0; | ||
| 31 | |||
| 32 | // We always want a region for the nro. | ||
| 33 | regions[num_regions++] = {nro_heap_address, nro_heap_size}; | ||
| 34 | |||
| 35 | // If we have bss, create a region for bss. | ||
| 36 | if (bss_heap_size > 0) { | ||
| 37 | regions[num_regions++] = {bss_heap_address, bss_heap_size}; | ||
| 38 | } | ||
| 39 | |||
| 40 | return num_regions; | ||
| 41 | } | ||
| 42 | |||
| 43 | Result SetProcessMemoryPermission(Kernel::KProcess* process, u64 address, u64 size, | ||
| 44 | Kernel::Svc::MemoryPermission permission) { | ||
| 45 | auto& page_table = process->GetPageTable(); | ||
| 46 | |||
| 47 | // Set permission. | ||
| 48 | R_RETURN(page_table.SetProcessMemoryPermission(address, size, permission)); | ||
| 49 | } | ||
| 50 | |||
| 51 | Result UnmapProcessCodeMemory(Kernel::KProcess* process, u64 process_code_address, | ||
| 52 | const ProcessMemoryRegion* regions, size_t num_regions) { | ||
| 53 | // Get the total process memory region size. | ||
| 54 | const size_t total_size = GetTotalProcessMemoryRegionSize(regions, num_regions); | ||
| 55 | |||
| 56 | auto& page_table = process->GetPageTable(); | ||
| 57 | |||
| 58 | // Unmap each region in order. | ||
| 59 | size_t cur_offset = total_size; | ||
| 60 | for (size_t i = 0; i < num_regions; ++i) { | ||
| 61 | // We want to unmap in reverse order. | ||
| 62 | const auto& cur_region = regions[num_regions - 1 - i]; | ||
| 63 | |||
| 64 | // Subtract to update the current offset. | ||
| 65 | cur_offset -= cur_region.size; | ||
| 66 | |||
| 67 | // Unmap. | ||
| 68 | R_TRY(page_table.UnmapCodeMemory(process_code_address + cur_offset, cur_region.address, | ||
| 69 | cur_region.size)); | ||
| 70 | } | ||
| 71 | |||
| 72 | R_SUCCEED(); | ||
| 73 | } | ||
| 74 | |||
| 75 | Result EnsureGuardPages(Kernel::KProcessPageTable& page_table, u64 map_address, u64 map_size) { | ||
| 76 | Kernel::KMemoryInfo memory_info; | ||
| 77 | Kernel::Svc::PageInfo page_info; | ||
| 78 | |||
| 79 | // Ensure page before mapping is unmapped. | ||
| 80 | R_TRY(page_table.QueryInfo(std::addressof(memory_info), std::addressof(page_info), | ||
| 81 | map_address - 1)); | ||
| 82 | R_UNLESS(memory_info.GetSvcState() == Kernel::Svc::MemoryState::Free, | ||
| 83 | Kernel::ResultInvalidState); | ||
| 84 | |||
| 85 | // Ensure page after mapping is unmapped. | ||
| 86 | R_TRY(page_table.QueryInfo(std::addressof(memory_info), std::addressof(page_info), | ||
| 87 | map_address + map_size)); | ||
| 88 | R_UNLESS(memory_info.GetSvcState() == Kernel::Svc::MemoryState::Free, | ||
| 89 | Kernel::ResultInvalidState); | ||
| 90 | |||
| 91 | // Successfully verified guard pages. | ||
| 92 | R_SUCCEED(); | ||
| 93 | } | ||
| 94 | |||
| 95 | Result MapProcessCodeMemory(u64* out, Kernel::KProcess* process, const ProcessMemoryRegion* regions, | ||
| 96 | size_t num_regions, std::mt19937_64& generate_random) { | ||
| 97 | auto& page_table = process->GetPageTable(); | ||
| 98 | const u64 alias_code_start = | ||
| 99 | GetInteger(page_table.GetAliasCodeRegionStart()) / Kernel::PageSize; | ||
| 100 | const u64 alias_code_size = page_table.GetAliasCodeRegionSize() / Kernel::PageSize; | ||
| 101 | |||
| 102 | for (size_t trial = 0; trial < 64; trial++) { | ||
| 103 | // Generate a new trial address. | ||
| 104 | const u64 mapped_address = | ||
| 105 | (alias_code_start + (generate_random() % alias_code_size)) * Kernel::PageSize; | ||
| 106 | |||
| 107 | const auto MapRegions = [&] { | ||
| 108 | // Map the regions in order. | ||
| 109 | u64 mapped_size = 0; | ||
| 110 | for (size_t i = 0; i < num_regions; ++i) { | ||
| 111 | // If we fail, unmap up to where we've mapped. | ||
| 112 | ON_RESULT_FAILURE { | ||
| 113 | R_ASSERT(UnmapProcessCodeMemory(process, mapped_address, regions, i)); | ||
| 114 | }; | ||
| 115 | |||
| 116 | // Map the current region. | ||
| 117 | R_TRY(page_table.MapCodeMemory(mapped_address + mapped_size, regions[i].address, | ||
| 118 | regions[i].size)); | ||
| 119 | |||
| 120 | mapped_size += regions[i].size; | ||
| 121 | } | ||
| 122 | |||
| 123 | // If we fail, unmap all mapped regions. | ||
| 124 | ON_RESULT_FAILURE { | ||
| 125 | R_ASSERT(UnmapProcessCodeMemory(process, mapped_address, regions, num_regions)); | ||
| 126 | }; | ||
| 127 | |||
| 128 | // Ensure guard pages. | ||
| 129 | R_RETURN(EnsureGuardPages(page_table, mapped_address, mapped_size)); | ||
| 130 | }; | ||
| 131 | |||
| 132 | if (R_SUCCEEDED(MapRegions())) { | ||
| 133 | // Set the output address. | ||
| 134 | *out = mapped_address; | ||
| 135 | R_SUCCEED(); | ||
| 136 | } | ||
| 137 | } | ||
| 138 | |||
| 139 | // We failed to map anything. | ||
| 140 | R_THROW(RO::ResultOutOfAddressSpace); | ||
| 141 | } | ||
| 142 | |||
| 143 | } // namespace | ||
| 144 | |||
| 145 | Result MapNro(u64* out_base_address, Kernel::KProcess* process, u64 nro_heap_address, | ||
| 146 | u64 nro_heap_size, u64 bss_heap_address, u64 bss_heap_size, | ||
| 147 | std::mt19937_64& generate_random) { | ||
| 148 | // Set up the process memory regions. | ||
| 149 | std::array<ProcessMemoryRegion, 2> regions{}; | ||
| 150 | const size_t num_regions = SetupNroProcessMemoryRegions( | ||
| 151 | regions.data(), nro_heap_address, nro_heap_size, bss_heap_address, bss_heap_size); | ||
| 152 | |||
| 153 | // Re-map the nro/bss as code memory in the destination process. | ||
| 154 | R_RETURN(MapProcessCodeMemory(out_base_address, process, regions.data(), num_regions, | ||
| 155 | generate_random)); | ||
| 156 | } | ||
| 157 | |||
| 158 | Result SetNroPerms(Kernel::KProcess* process, u64 base_address, u64 rx_size, u64 ro_size, | ||
| 159 | u64 rw_size) { | ||
| 160 | const u64 rx_offset = 0; | ||
| 161 | const u64 ro_offset = rx_offset + rx_size; | ||
| 162 | const u64 rw_offset = ro_offset + ro_size; | ||
| 163 | |||
| 164 | R_TRY(SetProcessMemoryPermission(process, base_address + rx_offset, rx_size, | ||
| 165 | Kernel::Svc::MemoryPermission::ReadExecute)); | ||
| 166 | R_TRY(SetProcessMemoryPermission(process, base_address + ro_offset, ro_size, | ||
| 167 | Kernel::Svc::MemoryPermission::Read)); | ||
| 168 | R_TRY(SetProcessMemoryPermission(process, base_address + rw_offset, rw_size, | ||
| 169 | Kernel::Svc::MemoryPermission::ReadWrite)); | ||
| 170 | |||
| 171 | R_SUCCEED(); | ||
| 172 | } | ||
| 173 | |||
| 174 | Result UnmapNro(Kernel::KProcess* process, u64 base_address, u64 nro_heap_address, | ||
| 175 | u64 nro_heap_size, u64 bss_heap_address, u64 bss_heap_size) { | ||
| 176 | // Set up the process memory regions. | ||
| 177 | std::array<ProcessMemoryRegion, 2> regions{}; | ||
| 178 | const size_t num_regions = SetupNroProcessMemoryRegions( | ||
| 179 | regions.data(), nro_heap_address, nro_heap_size, bss_heap_address, bss_heap_size); | ||
| 180 | |||
| 181 | // Unmap the nro/bss. | ||
| 182 | R_RETURN(UnmapProcessCodeMemory(process, base_address, regions.data(), num_regions)); | ||
| 183 | } | ||
| 184 | |||
| 185 | } // namespace Service::RO | ||
diff --git a/src/core/hle/service/ro/ro_nro_utils.h b/src/core/hle/service/ro/ro_nro_utils.h new file mode 100644 index 000000000..f7083a1ba --- /dev/null +++ b/src/core/hle/service/ro/ro_nro_utils.h | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <random> | ||
| 7 | |||
| 8 | #include "common/common_types.h" | ||
| 9 | |||
| 10 | namespace Kernel { | ||
| 11 | class KProcess; | ||
| 12 | } | ||
| 13 | |||
| 14 | union Result; | ||
| 15 | |||
| 16 | namespace Service::RO { | ||
| 17 | |||
| 18 | Result MapNro(u64* out_base_address, Kernel::KProcess* process, u64 nro_heap_address, | ||
| 19 | u64 nro_heap_size, u64 bss_heap_address, u64 bss_heap_size, | ||
| 20 | std::mt19937_64& generate_random); | ||
| 21 | Result SetNroPerms(Kernel::KProcess* process, u64 base_address, u64 rx_size, u64 ro_size, | ||
| 22 | u64 rw_size); | ||
| 23 | Result UnmapNro(Kernel::KProcess* process, u64 base_address, u64 nro_heap_address, | ||
| 24 | u64 nro_heap_size, u64 bss_heap_address, u64 bss_heap_size); | ||
| 25 | |||
| 26 | } // namespace Service::RO | ||
diff --git a/src/core/hle/service/ro/ro_results.h b/src/core/hle/service/ro/ro_results.h new file mode 100644 index 000000000..00f05c5a5 --- /dev/null +++ b/src/core/hle/service/ro/ro_results.h | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "core/hle/result.h" | ||
| 5 | |||
| 6 | namespace Service::RO { | ||
| 7 | |||
| 8 | constexpr Result ResultOutOfAddressSpace{ErrorModule::RO, 2}; | ||
| 9 | constexpr Result ResultAlreadyLoaded{ErrorModule::RO, 3}; | ||
| 10 | constexpr Result ResultInvalidNro{ErrorModule::RO, 4}; | ||
| 11 | constexpr Result ResultInvalidNrr{ErrorModule::RO, 6}; | ||
| 12 | constexpr Result ResultTooManyNro{ErrorModule::RO, 7}; | ||
| 13 | constexpr Result ResultTooManyNrr{ErrorModule::RO, 8}; | ||
| 14 | constexpr Result ResultNotAuthorized{ErrorModule::RO, 9}; | ||
| 15 | constexpr Result ResultInvalidNrrKind{ErrorModule::RO, 10}; | ||
| 16 | constexpr Result ResultInternalError{ErrorModule::RO, 1023}; | ||
| 17 | constexpr Result ResultInvalidAddress{ErrorModule::RO, 1025}; | ||
| 18 | constexpr Result ResultInvalidSize{ErrorModule::RO, 1026}; | ||
| 19 | constexpr Result ResultNotLoaded{ErrorModule::RO, 1028}; | ||
| 20 | constexpr Result ResultNotRegistered{ErrorModule::RO, 1029}; | ||
| 21 | constexpr Result ResultInvalidSession{ErrorModule::RO, 1030}; | ||
| 22 | constexpr Result ResultInvalidProcess{ErrorModule::RO, 1031}; | ||
| 23 | |||
| 24 | } // namespace Service::RO | ||
diff --git a/src/core/hle/service/ro/ro_types.h b/src/core/hle/service/ro/ro_types.h new file mode 100644 index 000000000..624d52ee5 --- /dev/null +++ b/src/core/hle/service/ro/ro_types.h | |||
| @@ -0,0 +1,181 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "common/assert.h" | ||
| 5 | #include "common/common_funcs.h" | ||
| 6 | #include "common/common_types.h" | ||
| 7 | |||
| 8 | namespace Service::RO { | ||
| 9 | |||
| 10 | enum class NrrKind : u8 { | ||
| 11 | User = 0, | ||
| 12 | JitPlugin = 1, | ||
| 13 | Count, | ||
| 14 | }; | ||
| 15 | |||
| 16 | static constexpr size_t ModuleIdSize = 0x20; | ||
| 17 | struct ModuleId { | ||
| 18 | std::array<u8, ModuleIdSize> data; | ||
| 19 | }; | ||
| 20 | static_assert(sizeof(ModuleId) == ModuleIdSize); | ||
| 21 | |||
| 22 | struct NrrCertification { | ||
| 23 | static constexpr size_t RsaKeySize = 0x100; | ||
| 24 | static constexpr size_t SignedSize = 0x120; | ||
| 25 | |||
| 26 | u64 program_id_mask; | ||
| 27 | u64 program_id_pattern; | ||
| 28 | std::array<u8, 0x10> reserved_10; | ||
| 29 | std::array<u8, RsaKeySize> modulus; | ||
| 30 | std::array<u8, RsaKeySize> signature; | ||
| 31 | }; | ||
| 32 | static_assert(sizeof(NrrCertification) == | ||
| 33 | NrrCertification::RsaKeySize + NrrCertification::SignedSize); | ||
| 34 | |||
| 35 | class NrrHeader { | ||
| 36 | public: | ||
| 37 | static constexpr u32 Magic = Common::MakeMagic('N', 'R', 'R', '0'); | ||
| 38 | |||
| 39 | public: | ||
| 40 | bool IsMagicValid() const { | ||
| 41 | return m_magic == Magic; | ||
| 42 | } | ||
| 43 | |||
| 44 | bool IsProgramIdValid() const { | ||
| 45 | return (m_program_id & m_certification.program_id_mask) == | ||
| 46 | m_certification.program_id_pattern; | ||
| 47 | } | ||
| 48 | |||
| 49 | NrrKind GetNrrKind() const { | ||
| 50 | const NrrKind kind = static_cast<NrrKind>(m_nrr_kind); | ||
| 51 | ASSERT(kind < NrrKind::Count); | ||
| 52 | return kind; | ||
| 53 | } | ||
| 54 | |||
| 55 | u64 GetProgramId() const { | ||
| 56 | return m_program_id; | ||
| 57 | } | ||
| 58 | |||
| 59 | u32 GetSize() const { | ||
| 60 | return m_size; | ||
| 61 | } | ||
| 62 | |||
| 63 | u32 GetNumHashes() const { | ||
| 64 | return m_num_hashes; | ||
| 65 | } | ||
| 66 | |||
| 67 | size_t GetHashesOffset() const { | ||
| 68 | return m_hashes_offset; | ||
| 69 | } | ||
| 70 | |||
| 71 | u32 GetKeyGeneration() const { | ||
| 72 | return m_key_generation; | ||
| 73 | } | ||
| 74 | |||
| 75 | const u8* GetCertificationSignature() const { | ||
| 76 | return m_certification.signature.data(); | ||
| 77 | } | ||
| 78 | |||
| 79 | const u8* GetCertificationSignedArea() const { | ||
| 80 | return reinterpret_cast<const u8*>(std::addressof(m_certification)); | ||
| 81 | } | ||
| 82 | |||
| 83 | const u8* GetCertificationModulus() const { | ||
| 84 | return m_certification.modulus.data(); | ||
| 85 | } | ||
| 86 | |||
| 87 | const u8* GetSignature() const { | ||
| 88 | return m_signature.data(); | ||
| 89 | } | ||
| 90 | |||
| 91 | size_t GetSignedAreaSize() const { | ||
| 92 | return m_size - GetSignedAreaOffset(); | ||
| 93 | } | ||
| 94 | |||
| 95 | static constexpr size_t GetSignedAreaOffset() { | ||
| 96 | return offsetof(NrrHeader, m_program_id); | ||
| 97 | } | ||
| 98 | |||
| 99 | private: | ||
| 100 | u32 m_magic; | ||
| 101 | u32 m_key_generation; | ||
| 102 | INSERT_PADDING_BYTES_NOINIT(8); | ||
| 103 | NrrCertification m_certification; | ||
| 104 | std::array<u8, 0x100> m_signature; | ||
| 105 | u64 m_program_id; | ||
| 106 | u32 m_size; | ||
| 107 | u8 m_nrr_kind; // 7.0.0+ | ||
| 108 | INSERT_PADDING_BYTES_NOINIT(3); | ||
| 109 | u32 m_hashes_offset; | ||
| 110 | u32 m_num_hashes; | ||
| 111 | INSERT_PADDING_BYTES_NOINIT(8); | ||
| 112 | }; | ||
| 113 | static_assert(sizeof(NrrHeader) == 0x350, "NrrHeader has wrong size"); | ||
| 114 | |||
| 115 | class NroHeader { | ||
| 116 | public: | ||
| 117 | static constexpr u32 Magic = Common::MakeMagic('N', 'R', 'O', '0'); | ||
| 118 | |||
| 119 | public: | ||
| 120 | bool IsMagicValid() const { | ||
| 121 | return m_magic == Magic; | ||
| 122 | } | ||
| 123 | |||
| 124 | u32 GetSize() const { | ||
| 125 | return m_size; | ||
| 126 | } | ||
| 127 | |||
| 128 | u32 GetTextOffset() const { | ||
| 129 | return m_text_offset; | ||
| 130 | } | ||
| 131 | |||
| 132 | u32 GetTextSize() const { | ||
| 133 | return m_text_size; | ||
| 134 | } | ||
| 135 | |||
| 136 | u32 GetRoOffset() const { | ||
| 137 | return m_ro_offset; | ||
| 138 | } | ||
| 139 | |||
| 140 | u32 GetRoSize() const { | ||
| 141 | return m_ro_size; | ||
| 142 | } | ||
| 143 | |||
| 144 | u32 GetRwOffset() const { | ||
| 145 | return m_rw_offset; | ||
| 146 | } | ||
| 147 | |||
| 148 | u32 GetRwSize() const { | ||
| 149 | return m_rw_size; | ||
| 150 | } | ||
| 151 | |||
| 152 | u32 GetBssSize() const { | ||
| 153 | return m_bss_size; | ||
| 154 | } | ||
| 155 | |||
| 156 | const ModuleId* GetModuleId() const { | ||
| 157 | return std::addressof(m_module_id); | ||
| 158 | } | ||
| 159 | |||
| 160 | private: | ||
| 161 | u32 m_entrypoint_insn; | ||
| 162 | u32 m_mod_offset; | ||
| 163 | INSERT_PADDING_BYTES_NOINIT(0x8); | ||
| 164 | u32 m_magic; | ||
| 165 | INSERT_PADDING_BYTES_NOINIT(0x4); | ||
| 166 | u32 m_size; | ||
| 167 | INSERT_PADDING_BYTES_NOINIT(0x4); | ||
| 168 | u32 m_text_offset; | ||
| 169 | u32 m_text_size; | ||
| 170 | u32 m_ro_offset; | ||
| 171 | u32 m_ro_size; | ||
| 172 | u32 m_rw_offset; | ||
| 173 | u32 m_rw_size; | ||
| 174 | u32 m_bss_size; | ||
| 175 | INSERT_PADDING_BYTES_NOINIT(0x4); | ||
| 176 | ModuleId m_module_id; | ||
| 177 | INSERT_PADDING_BYTES_NOINIT(0x20); | ||
| 178 | }; | ||
| 179 | static_assert(sizeof(NroHeader) == 0x80, "NroHeader has wrong size"); | ||
| 180 | |||
| 181 | } // namespace Service::RO | ||
diff --git a/src/core/hle/service/server_manager.cpp b/src/core/hle/service/server_manager.cpp index e2e399534..6808247a9 100644 --- a/src/core/hle/service/server_manager.cpp +++ b/src/core/hle/service/server_manager.cpp | |||
| @@ -93,13 +93,13 @@ Result ServerManager::RegisterSession(Kernel::KServerSession* session, | |||
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | Result ServerManager::RegisterNamedService(const std::string& service_name, | 95 | Result ServerManager::RegisterNamedService(const std::string& service_name, |
| 96 | std::shared_ptr<SessionRequestHandler>&& handler, | 96 | SessionRequestHandlerFactory&& handler_factory, |
| 97 | u32 max_sessions) { | 97 | u32 max_sessions) { |
| 98 | ASSERT(m_sessions.size() + m_ports.size() < MaximumWaitObjects); | 98 | ASSERT(m_sessions.size() + m_ports.size() < MaximumWaitObjects); |
| 99 | 99 | ||
| 100 | // Add the new server to sm:. | 100 | // Add the new server to sm:. |
| 101 | ASSERT(R_SUCCEEDED( | 101 | ASSERT(R_SUCCEEDED( |
| 102 | m_system.ServiceManager().RegisterService(service_name, max_sessions, handler))); | 102 | m_system.ServiceManager().RegisterService(service_name, max_sessions, handler_factory))); |
| 103 | 103 | ||
| 104 | // Get the registered port. | 104 | // Get the registered port. |
| 105 | Kernel::KPort* port{}; | 105 | Kernel::KPort* port{}; |
| @@ -112,7 +112,7 @@ Result ServerManager::RegisterNamedService(const std::string& service_name, | |||
| 112 | // Begin tracking the server port. | 112 | // Begin tracking the server port. |
| 113 | { | 113 | { |
| 114 | std::scoped_lock ll{m_list_mutex}; | 114 | std::scoped_lock ll{m_list_mutex}; |
| 115 | m_ports.emplace(std::addressof(port->GetServerPort()), std::move(handler)); | 115 | m_ports.emplace(std::addressof(port->GetServerPort()), std::move(handler_factory)); |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | // Signal the wakeup event. | 118 | // Signal the wakeup event. |
| @@ -121,8 +121,18 @@ Result ServerManager::RegisterNamedService(const std::string& service_name, | |||
| 121 | R_SUCCEED(); | 121 | R_SUCCEED(); |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | Result ServerManager::RegisterNamedService(const std::string& service_name, | ||
| 125 | std::shared_ptr<SessionRequestHandler>&& handler, | ||
| 126 | u32 max_sessions) { | ||
| 127 | // Make the factory. | ||
| 128 | const auto HandlerFactory = [handler]() { return handler; }; | ||
| 129 | |||
| 130 | // Register the service with the new factory. | ||
| 131 | R_RETURN(this->RegisterNamedService(service_name, std::move(HandlerFactory), max_sessions)); | ||
| 132 | } | ||
| 133 | |||
| 124 | Result ServerManager::ManageNamedPort(const std::string& service_name, | 134 | Result ServerManager::ManageNamedPort(const std::string& service_name, |
| 125 | std::shared_ptr<SessionRequestHandler>&& handler, | 135 | SessionRequestHandlerFactory&& handler_factory, |
| 126 | u32 max_sessions) { | 136 | u32 max_sessions) { |
| 127 | ASSERT(m_sessions.size() + m_ports.size() < MaximumWaitObjects); | 137 | ASSERT(m_sessions.size() + m_ports.size() < MaximumWaitObjects); |
| 128 | 138 | ||
| @@ -149,7 +159,7 @@ Result ServerManager::ManageNamedPort(const std::string& service_name, | |||
| 149 | // Begin tracking the server port. | 159 | // Begin tracking the server port. |
| 150 | { | 160 | { |
| 151 | std::scoped_lock ll{m_list_mutex}; | 161 | std::scoped_lock ll{m_list_mutex}; |
| 152 | m_ports.emplace(std::addressof(port->GetServerPort()), std::move(handler)); | 162 | m_ports.emplace(std::addressof(port->GetServerPort()), std::move(handler_factory)); |
| 153 | } | 163 | } |
| 154 | 164 | ||
| 155 | // We succeeded. | 165 | // We succeeded. |
| @@ -269,13 +279,13 @@ Result ServerManager::WaitAndProcessImpl() { | |||
| 269 | case HandleType::Port: { | 279 | case HandleType::Port: { |
| 270 | // Port signaled. | 280 | // Port signaled. |
| 271 | auto* port = wait_obj->DynamicCast<Kernel::KServerPort*>(); | 281 | auto* port = wait_obj->DynamicCast<Kernel::KServerPort*>(); |
| 272 | std::shared_ptr<SessionRequestHandler> handler; | 282 | SessionRequestHandlerFactory handler_factory; |
| 273 | 283 | ||
| 274 | // Remove from tracking. | 284 | // Remove from tracking. |
| 275 | { | 285 | { |
| 276 | std::scoped_lock ll{m_list_mutex}; | 286 | std::scoped_lock ll{m_list_mutex}; |
| 277 | ASSERT(m_ports.contains(port)); | 287 | ASSERT(m_ports.contains(port)); |
| 278 | m_ports.at(port).swap(handler); | 288 | m_ports.at(port).swap(handler_factory); |
| 279 | m_ports.erase(port); | 289 | m_ports.erase(port); |
| 280 | } | 290 | } |
| 281 | 291 | ||
| @@ -283,7 +293,7 @@ Result ServerManager::WaitAndProcessImpl() { | |||
| 283 | sl.unlock(); | 293 | sl.unlock(); |
| 284 | 294 | ||
| 285 | // Finish. | 295 | // Finish. |
| 286 | R_RETURN(this->OnPortEvent(port, std::move(handler))); | 296 | R_RETURN(this->OnPortEvent(port, std::move(handler_factory))); |
| 287 | } | 297 | } |
| 288 | case HandleType::Session: { | 298 | case HandleType::Session: { |
| 289 | // Session signaled. | 299 | // Session signaled. |
| @@ -333,19 +343,19 @@ Result ServerManager::WaitAndProcessImpl() { | |||
| 333 | } | 343 | } |
| 334 | 344 | ||
| 335 | Result ServerManager::OnPortEvent(Kernel::KServerPort* port, | 345 | Result ServerManager::OnPortEvent(Kernel::KServerPort* port, |
| 336 | std::shared_ptr<SessionRequestHandler>&& handler) { | 346 | SessionRequestHandlerFactory&& handler_factory) { |
| 337 | // Accept a new server session. | 347 | // Accept a new server session. |
| 338 | Kernel::KServerSession* session = port->AcceptSession(); | 348 | Kernel::KServerSession* session = port->AcceptSession(); |
| 339 | ASSERT(session != nullptr); | 349 | ASSERT(session != nullptr); |
| 340 | 350 | ||
| 341 | // Create the session manager and install the handler. | 351 | // Create the session manager and install the handler. |
| 342 | auto manager = std::make_shared<SessionRequestManager>(m_system.Kernel(), *this); | 352 | auto manager = std::make_shared<SessionRequestManager>(m_system.Kernel(), *this); |
| 343 | manager->SetSessionHandler(std::shared_ptr(handler)); | 353 | manager->SetSessionHandler(handler_factory()); |
| 344 | 354 | ||
| 345 | // Track the server session. | 355 | // Track the server session. |
| 346 | { | 356 | { |
| 347 | std::scoped_lock ll{m_list_mutex}; | 357 | std::scoped_lock ll{m_list_mutex}; |
| 348 | m_ports.emplace(port, std::move(handler)); | 358 | m_ports.emplace(port, std::move(handler_factory)); |
| 349 | m_sessions.emplace(session, std::move(manager)); | 359 | m_sessions.emplace(session, std::move(manager)); |
| 350 | } | 360 | } |
| 351 | 361 | ||
diff --git a/src/core/hle/service/server_manager.h b/src/core/hle/service/server_manager.h index 58b0a0832..c4bc07262 100644 --- a/src/core/hle/service/server_manager.h +++ b/src/core/hle/service/server_manager.h | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #include "common/polyfill_thread.h" | 13 | #include "common/polyfill_thread.h" |
| 14 | #include "common/thread.h" | 14 | #include "common/thread.h" |
| 15 | #include "core/hle/result.h" | 15 | #include "core/hle/result.h" |
| 16 | #include "core/hle/service/hle_ipc.h" | ||
| 16 | #include "core/hle/service/mutex.h" | 17 | #include "core/hle/service/mutex.h" |
| 17 | 18 | ||
| 18 | namespace Core { | 19 | namespace Core { |
| @@ -28,10 +29,6 @@ class KSynchronizationObject; | |||
| 28 | 29 | ||
| 29 | namespace Service { | 30 | namespace Service { |
| 30 | 31 | ||
| 31 | class HLERequestContext; | ||
| 32 | class SessionRequestHandler; | ||
| 33 | class SessionRequestManager; | ||
| 34 | |||
| 35 | class ServerManager { | 32 | class ServerManager { |
| 36 | public: | 33 | public: |
| 37 | explicit ServerManager(Core::System& system); | 34 | explicit ServerManager(Core::System& system); |
| @@ -40,10 +37,13 @@ public: | |||
| 40 | Result RegisterSession(Kernel::KServerSession* session, | 37 | Result RegisterSession(Kernel::KServerSession* session, |
| 41 | std::shared_ptr<SessionRequestManager> manager); | 38 | std::shared_ptr<SessionRequestManager> manager); |
| 42 | Result RegisterNamedService(const std::string& service_name, | 39 | Result RegisterNamedService(const std::string& service_name, |
| 40 | SessionRequestHandlerFactory&& handler_factory, | ||
| 41 | u32 max_sessions = 64); | ||
| 42 | Result RegisterNamedService(const std::string& service_name, | ||
| 43 | std::shared_ptr<SessionRequestHandler>&& handler, | 43 | std::shared_ptr<SessionRequestHandler>&& handler, |
| 44 | u32 max_sessions = 64); | 44 | u32 max_sessions = 64); |
| 45 | Result ManageNamedPort(const std::string& service_name, | 45 | Result ManageNamedPort(const std::string& service_name, |
| 46 | std::shared_ptr<SessionRequestHandler>&& handler, u32 max_sessions = 64); | 46 | SessionRequestHandlerFactory&& handler_factory, u32 max_sessions = 64); |
| 47 | Result ManageDeferral(Kernel::KEvent** out_event); | 47 | Result ManageDeferral(Kernel::KEvent** out_event); |
| 48 | 48 | ||
| 49 | Result LoopProcess(); | 49 | Result LoopProcess(); |
| @@ -56,7 +56,7 @@ private: | |||
| 56 | 56 | ||
| 57 | Result LoopProcessImpl(); | 57 | Result LoopProcessImpl(); |
| 58 | Result WaitAndProcessImpl(); | 58 | Result WaitAndProcessImpl(); |
| 59 | Result OnPortEvent(Kernel::KServerPort* port, std::shared_ptr<SessionRequestHandler>&& handler); | 59 | Result OnPortEvent(Kernel::KServerPort* port, SessionRequestHandlerFactory&& handler_factory); |
| 60 | Result OnSessionEvent(Kernel::KServerSession* session, | 60 | Result OnSessionEvent(Kernel::KServerSession* session, |
| 61 | std::shared_ptr<SessionRequestManager>&& manager); | 61 | std::shared_ptr<SessionRequestManager>&& manager); |
| 62 | Result OnDeferralEvent(std::list<RequestState>&& deferrals); | 62 | Result OnDeferralEvent(std::list<RequestState>&& deferrals); |
| @@ -68,7 +68,7 @@ private: | |||
| 68 | std::mutex m_list_mutex; | 68 | std::mutex m_list_mutex; |
| 69 | 69 | ||
| 70 | // Guest state tracking | 70 | // Guest state tracking |
| 71 | std::map<Kernel::KServerPort*, std::shared_ptr<SessionRequestHandler>> m_ports{}; | 71 | std::map<Kernel::KServerPort*, SessionRequestHandlerFactory> m_ports{}; |
| 72 | std::map<Kernel::KServerSession*, std::shared_ptr<SessionRequestManager>> m_sessions{}; | 72 | std::map<Kernel::KServerSession*, std::shared_ptr<SessionRequestManager>> m_sessions{}; |
| 73 | Kernel::KEvent* m_event{}; | 73 | Kernel::KEvent* m_event{}; |
| 74 | Kernel::KEvent* m_deferral_event{}; | 74 | Kernel::KEvent* m_deferral_event{}; |
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 0ad607391..00531b021 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp | |||
| @@ -59,6 +59,7 @@ | |||
| 59 | #include "core/hle/service/prepo/prepo.h" | 59 | #include "core/hle/service/prepo/prepo.h" |
| 60 | #include "core/hle/service/psc/psc.h" | 60 | #include "core/hle/service/psc/psc.h" |
| 61 | #include "core/hle/service/ptm/ptm.h" | 61 | #include "core/hle/service/ptm/ptm.h" |
| 62 | #include "core/hle/service/ro/ro.h" | ||
| 62 | #include "core/hle/service/service.h" | 63 | #include "core/hle/service/service.h" |
| 63 | #include "core/hle/service/set/settings.h" | 64 | #include "core/hle/service/set/settings.h" |
| 64 | #include "core/hle/service/sm/sm.h" | 65 | #include "core/hle/service/sm/sm.h" |
| @@ -270,6 +271,7 @@ Services::Services(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system | |||
| 270 | kernel.RunOnGuestCoreProcess("ProcessManager", [&] { PM::LoopProcess(system); }); | 271 | kernel.RunOnGuestCoreProcess("ProcessManager", [&] { PM::LoopProcess(system); }); |
| 271 | kernel.RunOnGuestCoreProcess("psc", [&] { PSC::LoopProcess(system); }); | 272 | kernel.RunOnGuestCoreProcess("psc", [&] { PSC::LoopProcess(system); }); |
| 272 | kernel.RunOnGuestCoreProcess("ptm", [&] { PTM::LoopProcess(system); }); | 273 | kernel.RunOnGuestCoreProcess("ptm", [&] { PTM::LoopProcess(system); }); |
| 274 | kernel.RunOnGuestCoreProcess("ro", [&] { RO::LoopProcess(system); }); | ||
| 273 | kernel.RunOnGuestCoreProcess("settings", [&] { Set::LoopProcess(system); }); | 275 | kernel.RunOnGuestCoreProcess("settings", [&] { Set::LoopProcess(system); }); |
| 274 | kernel.RunOnGuestCoreProcess("spl", [&] { SPL::LoopProcess(system); }); | 276 | kernel.RunOnGuestCoreProcess("spl", [&] { SPL::LoopProcess(system); }); |
| 275 | kernel.RunOnGuestCoreProcess("ssl", [&] { SSL::LoopProcess(system); }); | 277 | kernel.RunOnGuestCoreProcess("ssl", [&] { SSL::LoopProcess(system); }); |
diff --git a/src/core/hle/service/set/appln_settings.cpp b/src/core/hle/service/set/appln_settings.cpp new file mode 100644 index 000000000..a5d802757 --- /dev/null +++ b/src/core/hle/service/set/appln_settings.cpp | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "core/hle/service/set/appln_settings.h" | ||
| 5 | |||
| 6 | namespace Service::Set { | ||
| 7 | |||
| 8 | ApplnSettings DefaultApplnSettings() { | ||
| 9 | return {}; | ||
| 10 | } | ||
| 11 | |||
| 12 | } // namespace Service::Set | ||
diff --git a/src/core/hle/service/set/appln_settings.h b/src/core/hle/service/set/appln_settings.h new file mode 100644 index 000000000..b07df0ee7 --- /dev/null +++ b/src/core/hle/service/set/appln_settings.h | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <array> | ||
| 7 | |||
| 8 | #include "common/common_types.h" | ||
| 9 | |||
| 10 | namespace Service::Set { | ||
| 11 | struct ApplnSettings { | ||
| 12 | std::array<u8, 0x10> reserved_000; | ||
| 13 | |||
| 14 | // nn::util::Uuid MiiAuthorId, copied from system settings 0x94B0 | ||
| 15 | std::array<u8, 0x10> mii_author_id; | ||
| 16 | |||
| 17 | std::array<u8, 0x30> reserved_020; | ||
| 18 | |||
| 19 | // nn::settings::system::ServiceDiscoveryControlSettings | ||
| 20 | std::array<u8, 0x4> service_discovery_control_settings; | ||
| 21 | |||
| 22 | std::array<u8, 0x20> reserved_054; | ||
| 23 | |||
| 24 | bool in_repair_process_enable_flag; | ||
| 25 | |||
| 26 | std::array<u8, 0x3> pad_075; | ||
| 27 | }; | ||
| 28 | static_assert(offsetof(ApplnSettings, mii_author_id) == 0x10); | ||
| 29 | static_assert(offsetof(ApplnSettings, service_discovery_control_settings) == 0x50); | ||
| 30 | static_assert(offsetof(ApplnSettings, in_repair_process_enable_flag) == 0x74); | ||
| 31 | static_assert(sizeof(ApplnSettings) == 0x78, "ApplnSettings has the wrong size!"); | ||
| 32 | |||
| 33 | ApplnSettings DefaultApplnSettings(); | ||
| 34 | |||
| 35 | } // namespace Service::Set | ||
diff --git a/src/core/hle/service/set/device_settings.cpp b/src/core/hle/service/set/device_settings.cpp new file mode 100644 index 000000000..e423ce38a --- /dev/null +++ b/src/core/hle/service/set/device_settings.cpp | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "core/hle/service/set/device_settings.h" | ||
| 5 | |||
| 6 | namespace Service::Set { | ||
| 7 | |||
| 8 | DeviceSettings DefaultDeviceSettings() { | ||
| 9 | return {}; | ||
| 10 | } | ||
| 11 | |||
| 12 | } // namespace Service::Set | ||
diff --git a/src/core/hle/service/set/device_settings.h b/src/core/hle/service/set/device_settings.h new file mode 100644 index 000000000..b6cfe04f2 --- /dev/null +++ b/src/core/hle/service/set/device_settings.h | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <array> | ||
| 7 | |||
| 8 | #include "common/common_types.h" | ||
| 9 | |||
| 10 | namespace Service::Set { | ||
| 11 | struct DeviceSettings { | ||
| 12 | std::array<u8, 0x10> reserved_000; | ||
| 13 | |||
| 14 | // nn::settings::BatteryLot | ||
| 15 | std::array<u8, 0x18> ptm_battery_lot; | ||
| 16 | // nn::settings::system::PtmFuelGaugeParameter | ||
| 17 | std::array<u8, 0x18> ptm_fuel_gauge_parameter; | ||
| 18 | u8 ptm_battery_version; | ||
| 19 | // nn::settings::system::PtmCycleCountReliability | ||
| 20 | u32 ptm_cycle_count_reliability; | ||
| 21 | |||
| 22 | std::array<u8, 0x48> reserved_048; | ||
| 23 | |||
| 24 | // nn::settings::system::AnalogStickUserCalibration L | ||
| 25 | std::array<u8, 0x10> analog_user_stick_calibration_l; | ||
| 26 | // nn::settings::system::AnalogStickUserCalibration R | ||
| 27 | std::array<u8, 0x10> analog_user_stick_calibration_r; | ||
| 28 | |||
| 29 | std::array<u8, 0x20> reserved_0B0; | ||
| 30 | |||
| 31 | // nn::settings::system::ConsoleSixAxisSensorAccelerationBias | ||
| 32 | std::array<u8, 0xC> console_six_axis_sensor_acceleration_bias; | ||
| 33 | // nn::settings::system::ConsoleSixAxisSensorAngularVelocityBias | ||
| 34 | std::array<u8, 0xC> console_six_axis_sensor_angular_velocity_bias; | ||
| 35 | // nn::settings::system::ConsoleSixAxisSensorAccelerationGain | ||
| 36 | std::array<u8, 0x24> console_six_axis_sensor_acceleration_gain; | ||
| 37 | // nn::settings::system::ConsoleSixAxisSensorAngularVelocityGain | ||
| 38 | std::array<u8, 0x24> console_six_axis_sensor_angular_velocity_gain; | ||
| 39 | // nn::settings::system::ConsoleSixAxisSensorAngularVelocityTimeBias | ||
| 40 | std::array<u8, 0xC> console_six_axis_sensor_angular_velocity_time_bias; | ||
| 41 | // nn::settings::system::ConsoleSixAxisSensorAngularAcceleration | ||
| 42 | std::array<u8, 0x24> console_six_axis_sensor_angular_acceleration; | ||
| 43 | }; | ||
| 44 | static_assert(offsetof(DeviceSettings, ptm_battery_lot) == 0x10); | ||
| 45 | static_assert(offsetof(DeviceSettings, ptm_cycle_count_reliability) == 0x44); | ||
| 46 | static_assert(offsetof(DeviceSettings, analog_user_stick_calibration_l) == 0x90); | ||
| 47 | static_assert(offsetof(DeviceSettings, console_six_axis_sensor_acceleration_bias) == 0xD0); | ||
| 48 | static_assert(offsetof(DeviceSettings, console_six_axis_sensor_angular_acceleration) == 0x13C); | ||
| 49 | static_assert(sizeof(DeviceSettings) == 0x160, "DeviceSettings has the wrong size!"); | ||
| 50 | |||
| 51 | DeviceSettings DefaultDeviceSettings(); | ||
| 52 | |||
| 53 | } // namespace Service::Set | ||
diff --git a/src/core/hle/service/set/private_settings.cpp b/src/core/hle/service/set/private_settings.cpp new file mode 100644 index 000000000..70bf65727 --- /dev/null +++ b/src/core/hle/service/set/private_settings.cpp | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "core/hle/service/set/private_settings.h" | ||
| 5 | |||
| 6 | namespace Service::Set { | ||
| 7 | |||
| 8 | PrivateSettings DefaultPrivateSettings() { | ||
| 9 | return {}; | ||
| 10 | } | ||
| 11 | |||
| 12 | } // namespace Service::Set | ||
diff --git a/src/core/hle/service/set/private_settings.h b/src/core/hle/service/set/private_settings.h new file mode 100644 index 000000000..b63eaf45c --- /dev/null +++ b/src/core/hle/service/set/private_settings.h | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <array> | ||
| 7 | |||
| 8 | #include "common/bit_field.h" | ||
| 9 | #include "common/common_funcs.h" | ||
| 10 | #include "common/common_types.h" | ||
| 11 | #include "common/uuid.h" | ||
| 12 | #include "core/hle/service/time/clock_types.h" | ||
| 13 | |||
| 14 | namespace Service::Set { | ||
| 15 | |||
| 16 | /// This is nn::settings::system::InitialLaunchFlag | ||
| 17 | struct InitialLaunchFlag { | ||
| 18 | union { | ||
| 19 | u32 raw{}; | ||
| 20 | |||
| 21 | BitField<0, 1, u32> InitialLaunchCompletionFlag; | ||
| 22 | BitField<8, 1, u32> InitialLaunchUserAdditionFlag; | ||
| 23 | BitField<16, 1, u32> InitialLaunchTimestampFlag; | ||
| 24 | }; | ||
| 25 | }; | ||
| 26 | static_assert(sizeof(InitialLaunchFlag) == 4, "InitialLaunchFlag is an invalid size"); | ||
| 27 | |||
| 28 | /// This is nn::settings::system::InitialLaunchSettings | ||
| 29 | struct InitialLaunchSettings { | ||
| 30 | InitialLaunchFlag flags; | ||
| 31 | INSERT_PADDING_BYTES(0x4); | ||
| 32 | Service::Time::Clock::SteadyClockTimePoint timestamp; | ||
| 33 | }; | ||
| 34 | static_assert(sizeof(InitialLaunchSettings) == 0x20, "InitialLaunchSettings is incorrect size"); | ||
| 35 | |||
| 36 | #pragma pack(push, 4) | ||
| 37 | struct InitialLaunchSettingsPacked { | ||
| 38 | InitialLaunchFlag flags; | ||
| 39 | Service::Time::Clock::SteadyClockTimePoint timestamp; | ||
| 40 | }; | ||
| 41 | #pragma pack(pop) | ||
| 42 | static_assert(sizeof(InitialLaunchSettingsPacked) == 0x1C, | ||
| 43 | "InitialLaunchSettingsPacked is incorrect size"); | ||
| 44 | |||
| 45 | struct PrivateSettings { | ||
| 46 | std::array<u8, 0x10> reserved_00; | ||
| 47 | |||
| 48 | // nn::settings::system::InitialLaunchSettings | ||
| 49 | InitialLaunchSettings initial_launch_settings; | ||
| 50 | |||
| 51 | std::array<u8, 0x20> reserved_30; | ||
| 52 | |||
| 53 | Common::UUID external_clock_source_id; | ||
| 54 | s64 shutdown_rtc_value; | ||
| 55 | s64 external_steady_clock_internal_offset; | ||
| 56 | |||
| 57 | std::array<u8, 0x60> reserved_70; | ||
| 58 | |||
| 59 | // nn::settings::system::PlatformRegion | ||
| 60 | std::array<u8, 0x4> platform_region; | ||
| 61 | |||
| 62 | std::array<u8, 0x4> reserved_D4; | ||
| 63 | }; | ||
| 64 | static_assert(offsetof(PrivateSettings, initial_launch_settings) == 0x10); | ||
| 65 | static_assert(offsetof(PrivateSettings, external_clock_source_id) == 0x50); | ||
| 66 | static_assert(offsetof(PrivateSettings, reserved_70) == 0x70); | ||
| 67 | static_assert(offsetof(PrivateSettings, platform_region) == 0xD0); | ||
| 68 | static_assert(sizeof(PrivateSettings) == 0xD8, "PrivateSettings has the wrong size!"); | ||
| 69 | |||
| 70 | PrivateSettings DefaultPrivateSettings(); | ||
| 71 | |||
| 72 | } // namespace Service::Set | ||
diff --git a/src/core/hle/service/set/set.h b/src/core/hle/service/set/set.h index b61a3560d..6ef3da410 100644 --- a/src/core/hle/service/set/set.h +++ b/src/core/hle/service/set/set.h | |||
| @@ -4,35 +4,13 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "core/hle/service/service.h" | 6 | #include "core/hle/service/service.h" |
| 7 | #include "core/hle/service/set/system_settings.h" | ||
| 7 | 8 | ||
| 8 | namespace Core { | 9 | namespace Core { |
| 9 | class System; | 10 | class System; |
| 10 | } | 11 | } |
| 11 | 12 | ||
| 12 | namespace Service::Set { | 13 | namespace Service::Set { |
| 13 | |||
| 14 | /// This is "nn::settings::LanguageCode", which is a NUL-terminated string stored in a u64. | ||
| 15 | enum class LanguageCode : u64 { | ||
| 16 | JA = 0x000000000000616A, | ||
| 17 | EN_US = 0x00000053552D6E65, | ||
| 18 | FR = 0x0000000000007266, | ||
| 19 | DE = 0x0000000000006564, | ||
| 20 | IT = 0x0000000000007469, | ||
| 21 | ES = 0x0000000000007365, | ||
| 22 | ZH_CN = 0x0000004E432D687A, | ||
| 23 | KO = 0x0000000000006F6B, | ||
| 24 | NL = 0x0000000000006C6E, | ||
| 25 | PT = 0x0000000000007470, | ||
| 26 | RU = 0x0000000000007572, | ||
| 27 | ZH_TW = 0x00000057542D687A, | ||
| 28 | EN_GB = 0x00000042472D6E65, | ||
| 29 | FR_CA = 0x00000041432D7266, | ||
| 30 | ES_419 = 0x00003931342D7365, | ||
| 31 | ZH_HANS = 0x00736E61482D687A, | ||
| 32 | ZH_HANT = 0x00746E61482D687A, | ||
| 33 | PT_BR = 0x00000052422D7470, | ||
| 34 | }; | ||
| 35 | |||
| 36 | enum class KeyboardLayout : u64 { | 14 | enum class KeyboardLayout : u64 { |
| 37 | Japanese = 0, | 15 | Japanese = 0, |
| 38 | EnglishUs = 1, | 16 | EnglishUs = 1, |
diff --git a/src/core/hle/service/set/set_sys.cpp b/src/core/hle/service/set/set_sys.cpp index 48304e6d1..0653779d5 100644 --- a/src/core/hle/service/set/set_sys.cpp +++ b/src/core/hle/service/set/set_sys.cpp | |||
| @@ -1,7 +1,12 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include <fstream> | ||
| 5 | |||
| 4 | #include "common/assert.h" | 6 | #include "common/assert.h" |
| 7 | #include "common/fs/file.h" | ||
| 8 | #include "common/fs/fs.h" | ||
| 9 | #include "common/fs/path_util.h" | ||
| 5 | #include "common/logging/log.h" | 10 | #include "common/logging/log.h" |
| 6 | #include "common/settings.h" | 11 | #include "common/settings.h" |
| 7 | #include "common/string_util.h" | 12 | #include "common/string_util.h" |
| @@ -19,6 +24,16 @@ | |||
| 19 | 24 | ||
| 20 | namespace Service::Set { | 25 | namespace Service::Set { |
| 21 | 26 | ||
| 27 | namespace { | ||
| 28 | constexpr u32 SETTINGS_VERSION{1u}; | ||
| 29 | constexpr auto SETTINGS_MAGIC = Common::MakeMagic('y', 'u', 'z', 'u', '_', 's', 'e', 't'); | ||
| 30 | struct SettingsHeader { | ||
| 31 | u64 magic; | ||
| 32 | u32 version; | ||
| 33 | u32 reserved; | ||
| 34 | }; | ||
| 35 | } // Anonymous namespace | ||
| 36 | |||
| 22 | Result GetFirmwareVersionImpl(FirmwareVersionFormat& out_firmware, Core::System& system, | 37 | Result GetFirmwareVersionImpl(FirmwareVersionFormat& out_firmware, Core::System& system, |
| 23 | GetFirmwareVersionType type) { | 38 | GetFirmwareVersionType type) { |
| 24 | constexpr u64 FirmwareVersionSystemDataId = 0x0100000000000809; | 39 | constexpr u64 FirmwareVersionSystemDataId = 0x0100000000000809; |
| @@ -72,11 +87,120 @@ Result GetFirmwareVersionImpl(FirmwareVersionFormat& out_firmware, Core::System& | |||
| 72 | return ResultSuccess; | 87 | return ResultSuccess; |
| 73 | } | 88 | } |
| 74 | 89 | ||
| 90 | bool SET_SYS::LoadSettingsFile(std::filesystem::path& path, auto&& default_func) { | ||
| 91 | using settings_type = decltype(default_func()); | ||
| 92 | |||
| 93 | if (!Common::FS::CreateDirs(path)) { | ||
| 94 | return false; | ||
| 95 | } | ||
| 96 | |||
| 97 | auto settings_file = path / "settings.dat"; | ||
| 98 | auto exists = std::filesystem::exists(settings_file); | ||
| 99 | auto file_size_ok = exists && std::filesystem::file_size(settings_file) == | ||
| 100 | sizeof(SettingsHeader) + sizeof(settings_type); | ||
| 101 | |||
| 102 | auto ResetToDefault = [&]() { | ||
| 103 | auto default_settings{default_func()}; | ||
| 104 | |||
| 105 | SettingsHeader hdr{ | ||
| 106 | .magic = SETTINGS_MAGIC, | ||
| 107 | .version = SETTINGS_VERSION, | ||
| 108 | .reserved = 0u, | ||
| 109 | }; | ||
| 110 | |||
| 111 | std::ofstream out_settings_file(settings_file, std::ios::out | std::ios::binary); | ||
| 112 | out_settings_file.write(reinterpret_cast<const char*>(&hdr), sizeof(hdr)); | ||
| 113 | out_settings_file.write(reinterpret_cast<const char*>(&default_settings), | ||
| 114 | sizeof(settings_type)); | ||
| 115 | out_settings_file.flush(); | ||
| 116 | out_settings_file.close(); | ||
| 117 | }; | ||
| 118 | |||
| 119 | constexpr auto IsHeaderValid = [](std::ifstream& file) -> bool { | ||
| 120 | if (!file.is_open()) { | ||
| 121 | return false; | ||
| 122 | } | ||
| 123 | SettingsHeader hdr{}; | ||
| 124 | file.read(reinterpret_cast<char*>(&hdr), sizeof(hdr)); | ||
| 125 | return hdr.magic == SETTINGS_MAGIC && hdr.version == SETTINGS_VERSION; | ||
| 126 | }; | ||
| 127 | |||
| 128 | if (!exists || !file_size_ok) { | ||
| 129 | ResetToDefault(); | ||
| 130 | } | ||
| 131 | |||
| 132 | std::ifstream file(settings_file, std::ios::binary | std::ios::in); | ||
| 133 | if (!IsHeaderValid(file)) { | ||
| 134 | file.close(); | ||
| 135 | ResetToDefault(); | ||
| 136 | file = std::ifstream(settings_file, std::ios::binary | std::ios::in); | ||
| 137 | if (!IsHeaderValid(file)) { | ||
| 138 | return false; | ||
| 139 | } | ||
| 140 | } | ||
| 141 | |||
| 142 | if constexpr (std::is_same_v<settings_type, PrivateSettings>) { | ||
| 143 | file.read(reinterpret_cast<char*>(&m_private_settings), sizeof(settings_type)); | ||
| 144 | } else if constexpr (std::is_same_v<settings_type, DeviceSettings>) { | ||
| 145 | file.read(reinterpret_cast<char*>(&m_device_settings), sizeof(settings_type)); | ||
| 146 | } else if constexpr (std::is_same_v<settings_type, ApplnSettings>) { | ||
| 147 | file.read(reinterpret_cast<char*>(&m_appln_settings), sizeof(settings_type)); | ||
| 148 | } else if constexpr (std::is_same_v<settings_type, SystemSettings>) { | ||
| 149 | file.read(reinterpret_cast<char*>(&m_system_settings), sizeof(settings_type)); | ||
| 150 | } else { | ||
| 151 | UNREACHABLE(); | ||
| 152 | } | ||
| 153 | file.close(); | ||
| 154 | |||
| 155 | return true; | ||
| 156 | } | ||
| 157 | |||
| 158 | bool SET_SYS::StoreSettingsFile(std::filesystem::path& path, auto& settings) { | ||
| 159 | using settings_type = std::decay_t<decltype(settings)>; | ||
| 160 | |||
| 161 | if (!Common::FS::IsDir(path)) { | ||
| 162 | return false; | ||
| 163 | } | ||
| 164 | |||
| 165 | auto settings_base = path / "settings"; | ||
| 166 | auto settings_tmp_file = settings_base; | ||
| 167 | settings_tmp_file = settings_tmp_file.replace_extension("tmp"); | ||
| 168 | std::ofstream file(settings_tmp_file, std::ios::binary | std::ios::out); | ||
| 169 | if (!file.is_open()) { | ||
| 170 | return false; | ||
| 171 | } | ||
| 172 | |||
| 173 | SettingsHeader hdr{ | ||
| 174 | .magic = SETTINGS_MAGIC, | ||
| 175 | .version = SETTINGS_VERSION, | ||
| 176 | .reserved = 0u, | ||
| 177 | }; | ||
| 178 | file.write(reinterpret_cast<const char*>(&hdr), sizeof(hdr)); | ||
| 179 | |||
| 180 | if constexpr (std::is_same_v<settings_type, PrivateSettings>) { | ||
| 181 | file.write(reinterpret_cast<const char*>(&m_private_settings), sizeof(settings_type)); | ||
| 182 | } else if constexpr (std::is_same_v<settings_type, DeviceSettings>) { | ||
| 183 | file.write(reinterpret_cast<const char*>(&m_device_settings), sizeof(settings_type)); | ||
| 184 | } else if constexpr (std::is_same_v<settings_type, ApplnSettings>) { | ||
| 185 | file.write(reinterpret_cast<const char*>(&m_appln_settings), sizeof(settings_type)); | ||
| 186 | } else if constexpr (std::is_same_v<settings_type, SystemSettings>) { | ||
| 187 | file.write(reinterpret_cast<const char*>(&m_system_settings), sizeof(settings_type)); | ||
| 188 | } else { | ||
| 189 | UNREACHABLE(); | ||
| 190 | } | ||
| 191 | file.close(); | ||
| 192 | |||
| 193 | std::filesystem::rename(settings_tmp_file, settings_base.replace_extension("dat")); | ||
| 194 | |||
| 195 | return true; | ||
| 196 | } | ||
| 197 | |||
| 75 | void SET_SYS::SetLanguageCode(HLERequestContext& ctx) { | 198 | void SET_SYS::SetLanguageCode(HLERequestContext& ctx) { |
| 76 | IPC::RequestParser rp{ctx}; | 199 | IPC::RequestParser rp{ctx}; |
| 77 | language_code_setting = rp.PopEnum<LanguageCode>(); | 200 | m_system_settings.language_code = rp.PopEnum<LanguageCode>(); |
| 201 | SetSaveNeeded(); | ||
| 78 | 202 | ||
| 79 | LOG_INFO(Service_SET, "called, language_code={}", language_code_setting); | 203 | LOG_INFO(Service_SET, "called, language_code={}", m_system_settings.language_code); |
| 80 | 204 | ||
| 81 | IPC::ResponseBuilder rb{ctx, 2}; | 205 | IPC::ResponseBuilder rb{ctx, 2}; |
| 82 | rb.Push(ResultSuccess); | 206 | rb.Push(ResultSuccess); |
| @@ -112,19 +236,68 @@ void SET_SYS::GetFirmwareVersion2(HLERequestContext& ctx) { | |||
| 112 | rb.Push(result); | 236 | rb.Push(result); |
| 113 | } | 237 | } |
| 114 | 238 | ||
| 239 | void SET_SYS::GetExternalSteadyClockSourceId(HLERequestContext& ctx) { | ||
| 240 | LOG_INFO(Service_SET, "called"); | ||
| 241 | |||
| 242 | Common::UUID id{}; | ||
| 243 | auto res = GetExternalSteadyClockSourceId(id); | ||
| 244 | |||
| 245 | IPC::ResponseBuilder rb{ctx, 2 + sizeof(Common::UUID) / sizeof(u32)}; | ||
| 246 | rb.Push(res); | ||
| 247 | rb.PushRaw(id); | ||
| 248 | } | ||
| 249 | |||
| 250 | void SET_SYS::SetExternalSteadyClockSourceId(HLERequestContext& ctx) { | ||
| 251 | LOG_INFO(Service_SET, "called"); | ||
| 252 | |||
| 253 | IPC::RequestParser rp{ctx}; | ||
| 254 | auto id{rp.PopRaw<Common::UUID>()}; | ||
| 255 | |||
| 256 | auto res = SetExternalSteadyClockSourceId(id); | ||
| 257 | |||
| 258 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 259 | rb.Push(res); | ||
| 260 | } | ||
| 261 | |||
| 262 | void SET_SYS::GetUserSystemClockContext(HLERequestContext& ctx) { | ||
| 263 | LOG_INFO(Service_SET, "called"); | ||
| 264 | |||
| 265 | Service::Time::Clock::SystemClockContext context{}; | ||
| 266 | auto res = GetUserSystemClockContext(context); | ||
| 267 | |||
| 268 | IPC::ResponseBuilder rb{ctx, | ||
| 269 | 2 + sizeof(Service::Time::Clock::SystemClockContext) / sizeof(u32)}; | ||
| 270 | rb.Push(res); | ||
| 271 | rb.PushRaw(context); | ||
| 272 | } | ||
| 273 | |||
| 274 | void SET_SYS::SetUserSystemClockContext(HLERequestContext& ctx) { | ||
| 275 | LOG_INFO(Service_SET, "called"); | ||
| 276 | |||
| 277 | IPC::RequestParser rp{ctx}; | ||
| 278 | auto context{rp.PopRaw<Service::Time::Clock::SystemClockContext>()}; | ||
| 279 | |||
| 280 | auto res = SetUserSystemClockContext(context); | ||
| 281 | |||
| 282 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 283 | rb.Push(res); | ||
| 284 | } | ||
| 285 | |||
| 115 | void SET_SYS::GetAccountSettings(HLERequestContext& ctx) { | 286 | void SET_SYS::GetAccountSettings(HLERequestContext& ctx) { |
| 116 | LOG_INFO(Service_SET, "called"); | 287 | LOG_INFO(Service_SET, "called"); |
| 117 | 288 | ||
| 118 | IPC::ResponseBuilder rb{ctx, 3}; | 289 | IPC::ResponseBuilder rb{ctx, 3}; |
| 119 | rb.Push(ResultSuccess); | 290 | rb.Push(ResultSuccess); |
| 120 | rb.PushRaw(account_settings); | 291 | rb.PushRaw(m_system_settings.account_settings); |
| 121 | } | 292 | } |
| 122 | 293 | ||
| 123 | void SET_SYS::SetAccountSettings(HLERequestContext& ctx) { | 294 | void SET_SYS::SetAccountSettings(HLERequestContext& ctx) { |
| 124 | IPC::RequestParser rp{ctx}; | 295 | IPC::RequestParser rp{ctx}; |
| 125 | account_settings = rp.PopRaw<AccountSettings>(); | 296 | m_system_settings.account_settings = rp.PopRaw<AccountSettings>(); |
| 297 | SetSaveNeeded(); | ||
| 126 | 298 | ||
| 127 | LOG_INFO(Service_SET, "called, account_settings_flags={}", account_settings.flags); | 299 | LOG_INFO(Service_SET, "called, account_settings_flags={}", |
| 300 | m_system_settings.account_settings.flags); | ||
| 128 | 301 | ||
| 129 | IPC::ResponseBuilder rb{ctx, 2}; | 302 | IPC::ResponseBuilder rb{ctx, 2}; |
| 130 | rb.Push(ResultSuccess); | 303 | rb.Push(ResultSuccess); |
| @@ -133,11 +306,11 @@ void SET_SYS::SetAccountSettings(HLERequestContext& ctx) { | |||
| 133 | void SET_SYS::GetEulaVersions(HLERequestContext& ctx) { | 306 | void SET_SYS::GetEulaVersions(HLERequestContext& ctx) { |
| 134 | LOG_INFO(Service_SET, "called"); | 307 | LOG_INFO(Service_SET, "called"); |
| 135 | 308 | ||
| 136 | ctx.WriteBuffer(eula_versions); | 309 | ctx.WriteBuffer(m_system_settings.eula_versions); |
| 137 | 310 | ||
| 138 | IPC::ResponseBuilder rb{ctx, 3}; | 311 | IPC::ResponseBuilder rb{ctx, 3}; |
| 139 | rb.Push(ResultSuccess); | 312 | rb.Push(ResultSuccess); |
| 140 | rb.Push(static_cast<u32>(eula_versions.size())); | 313 | rb.Push(m_system_settings.eula_version_count); |
| 141 | } | 314 | } |
| 142 | 315 | ||
| 143 | void SET_SYS::SetEulaVersions(HLERequestContext& ctx) { | 316 | void SET_SYS::SetEulaVersions(HLERequestContext& ctx) { |
| @@ -145,13 +318,12 @@ void SET_SYS::SetEulaVersions(HLERequestContext& ctx) { | |||
| 145 | const auto buffer_data = ctx.ReadBuffer(); | 318 | const auto buffer_data = ctx.ReadBuffer(); |
| 146 | 319 | ||
| 147 | LOG_INFO(Service_SET, "called, elements={}", elements); | 320 | LOG_INFO(Service_SET, "called, elements={}", elements); |
| 321 | ASSERT(elements <= m_system_settings.eula_versions.size()); | ||
| 148 | 322 | ||
| 149 | eula_versions.resize(elements); | 323 | m_system_settings.eula_version_count = static_cast<u32>(elements); |
| 150 | for (std::size_t index = 0; index < elements; index++) { | 324 | std::memcpy(&m_system_settings.eula_versions, buffer_data.data(), |
| 151 | const std::size_t start_index = index * sizeof(EulaVersion); | 325 | sizeof(EulaVersion) * elements); |
| 152 | memcpy(eula_versions.data() + start_index, buffer_data.data() + start_index, | 326 | SetSaveNeeded(); |
| 153 | sizeof(EulaVersion)); | ||
| 154 | } | ||
| 155 | 327 | ||
| 156 | IPC::ResponseBuilder rb{ctx, 2}; | 328 | IPC::ResponseBuilder rb{ctx, 2}; |
| 157 | rb.Push(ResultSuccess); | 329 | rb.Push(ResultSuccess); |
| @@ -162,14 +334,15 @@ void SET_SYS::GetColorSetId(HLERequestContext& ctx) { | |||
| 162 | 334 | ||
| 163 | IPC::ResponseBuilder rb{ctx, 3}; | 335 | IPC::ResponseBuilder rb{ctx, 3}; |
| 164 | rb.Push(ResultSuccess); | 336 | rb.Push(ResultSuccess); |
| 165 | rb.PushEnum(color_set); | 337 | rb.PushEnum(m_system_settings.color_set_id); |
| 166 | } | 338 | } |
| 167 | 339 | ||
| 168 | void SET_SYS::SetColorSetId(HLERequestContext& ctx) { | 340 | void SET_SYS::SetColorSetId(HLERequestContext& ctx) { |
| 169 | IPC::RequestParser rp{ctx}; | 341 | IPC::RequestParser rp{ctx}; |
| 170 | color_set = rp.PopEnum<ColorSet>(); | 342 | m_system_settings.color_set_id = rp.PopEnum<ColorSet>(); |
| 343 | SetSaveNeeded(); | ||
| 171 | 344 | ||
| 172 | LOG_DEBUG(Service_SET, "called, color_set={}", color_set); | 345 | LOG_DEBUG(Service_SET, "called, color_set={}", m_system_settings.color_set_id); |
| 173 | 346 | ||
| 174 | IPC::ResponseBuilder rb{ctx, 2}; | 347 | IPC::ResponseBuilder rb{ctx, 2}; |
| 175 | rb.Push(ResultSuccess); | 348 | rb.Push(ResultSuccess); |
| @@ -180,17 +353,21 @@ void SET_SYS::GetNotificationSettings(HLERequestContext& ctx) { | |||
| 180 | 353 | ||
| 181 | IPC::ResponseBuilder rb{ctx, 8}; | 354 | IPC::ResponseBuilder rb{ctx, 8}; |
| 182 | rb.Push(ResultSuccess); | 355 | rb.Push(ResultSuccess); |
| 183 | rb.PushRaw(notification_settings); | 356 | rb.PushRaw(m_system_settings.notification_settings); |
| 184 | } | 357 | } |
| 185 | 358 | ||
| 186 | void SET_SYS::SetNotificationSettings(HLERequestContext& ctx) { | 359 | void SET_SYS::SetNotificationSettings(HLERequestContext& ctx) { |
| 187 | IPC::RequestParser rp{ctx}; | 360 | IPC::RequestParser rp{ctx}; |
| 188 | notification_settings = rp.PopRaw<NotificationSettings>(); | 361 | m_system_settings.notification_settings = rp.PopRaw<NotificationSettings>(); |
| 362 | SetSaveNeeded(); | ||
| 189 | 363 | ||
| 190 | LOG_INFO(Service_SET, "called, flags={}, volume={}, head_time={}:{}, tailt_time={}:{}", | 364 | LOG_INFO(Service_SET, "called, flags={}, volume={}, head_time={}:{}, tailt_time={}:{}", |
| 191 | notification_settings.flags.raw, notification_settings.volume, | 365 | m_system_settings.notification_settings.flags.raw, |
| 192 | notification_settings.start_time.hour, notification_settings.start_time.minute, | 366 | m_system_settings.notification_settings.volume, |
| 193 | notification_settings.stop_time.hour, notification_settings.stop_time.minute); | 367 | m_system_settings.notification_settings.start_time.hour, |
| 368 | m_system_settings.notification_settings.start_time.minute, | ||
| 369 | m_system_settings.notification_settings.stop_time.hour, | ||
| 370 | m_system_settings.notification_settings.stop_time.minute); | ||
| 194 | 371 | ||
| 195 | IPC::ResponseBuilder rb{ctx, 2}; | 372 | IPC::ResponseBuilder rb{ctx, 2}; |
| 196 | rb.Push(ResultSuccess); | 373 | rb.Push(ResultSuccess); |
| @@ -199,11 +376,11 @@ void SET_SYS::SetNotificationSettings(HLERequestContext& ctx) { | |||
| 199 | void SET_SYS::GetAccountNotificationSettings(HLERequestContext& ctx) { | 376 | void SET_SYS::GetAccountNotificationSettings(HLERequestContext& ctx) { |
| 200 | LOG_INFO(Service_SET, "called"); | 377 | LOG_INFO(Service_SET, "called"); |
| 201 | 378 | ||
| 202 | ctx.WriteBuffer(account_notifications); | 379 | ctx.WriteBuffer(m_system_settings.account_notification_settings); |
| 203 | 380 | ||
| 204 | IPC::ResponseBuilder rb{ctx, 3}; | 381 | IPC::ResponseBuilder rb{ctx, 3}; |
| 205 | rb.Push(ResultSuccess); | 382 | rb.Push(ResultSuccess); |
| 206 | rb.Push(static_cast<u32>(account_notifications.size())); | 383 | rb.Push(m_system_settings.account_notification_settings_count); |
| 207 | } | 384 | } |
| 208 | 385 | ||
| 209 | void SET_SYS::SetAccountNotificationSettings(HLERequestContext& ctx) { | 386 | void SET_SYS::SetAccountNotificationSettings(HLERequestContext& ctx) { |
| @@ -212,12 +389,12 @@ void SET_SYS::SetAccountNotificationSettings(HLERequestContext& ctx) { | |||
| 212 | 389 | ||
| 213 | LOG_INFO(Service_SET, "called, elements={}", elements); | 390 | LOG_INFO(Service_SET, "called, elements={}", elements); |
| 214 | 391 | ||
| 215 | account_notifications.resize(elements); | 392 | ASSERT(elements <= m_system_settings.account_notification_settings.size()); |
| 216 | for (std::size_t index = 0; index < elements; index++) { | 393 | |
| 217 | const std::size_t start_index = index * sizeof(AccountNotificationSettings); | 394 | m_system_settings.account_notification_settings_count = static_cast<u32>(elements); |
| 218 | memcpy(account_notifications.data() + start_index, buffer_data.data() + start_index, | 395 | std::memcpy(&m_system_settings.account_notification_settings, buffer_data.data(), |
| 219 | sizeof(AccountNotificationSettings)); | 396 | elements * sizeof(AccountNotificationSettings)); |
| 220 | } | 397 | SetSaveNeeded(); |
| 221 | 398 | ||
| 222 | IPC::ResponseBuilder rb{ctx, 2}; | 399 | IPC::ResponseBuilder rb{ctx, 2}; |
| 223 | rb.Push(ResultSuccess); | 400 | rb.Push(ResultSuccess); |
| @@ -244,6 +421,14 @@ static Settings GetSettings() { | |||
| 244 | ret["hbloader"]["applet_heap_size"] = ToBytes(u64{0x0}); | 421 | ret["hbloader"]["applet_heap_size"] = ToBytes(u64{0x0}); |
| 245 | ret["hbloader"]["applet_heap_reservation_size"] = ToBytes(u64{0x8600000}); | 422 | ret["hbloader"]["applet_heap_reservation_size"] = ToBytes(u64{0x8600000}); |
| 246 | 423 | ||
| 424 | // Time | ||
| 425 | ret["time"]["notify_time_to_fs_interval_seconds"] = ToBytes(s32{600}); | ||
| 426 | ret["time"]["standard_network_clock_sufficient_accuracy_minutes"] = | ||
| 427 | ToBytes(s32{43200}); // 30 days | ||
| 428 | ret["time"]["standard_steady_clock_rtc_update_interval_minutes"] = ToBytes(s32{5}); | ||
| 429 | ret["time"]["standard_steady_clock_test_offset_minutes"] = ToBytes(s32{0}); | ||
| 430 | ret["time"]["standard_user_clock_initial_year"] = ToBytes(s32{2023}); | ||
| 431 | |||
| 247 | return ret; | 432 | return ret; |
| 248 | } | 433 | } |
| 249 | 434 | ||
| @@ -273,8 +458,6 @@ void SET_SYS::GetSettingsItemValueSize(HLERequestContext& ctx) { | |||
| 273 | } | 458 | } |
| 274 | 459 | ||
| 275 | void SET_SYS::GetSettingsItemValue(HLERequestContext& ctx) { | 460 | void SET_SYS::GetSettingsItemValue(HLERequestContext& ctx) { |
| 276 | LOG_DEBUG(Service_SET, "called"); | ||
| 277 | |||
| 278 | // The category of the setting. This corresponds to the top-level keys of | 461 | // The category of the setting. This corresponds to the top-level keys of |
| 279 | // system_settings.ini. | 462 | // system_settings.ini. |
| 280 | const auto setting_category_buf{ctx.ReadBuffer(0)}; | 463 | const auto setting_category_buf{ctx.ReadBuffer(0)}; |
| @@ -285,14 +468,13 @@ void SET_SYS::GetSettingsItemValue(HLERequestContext& ctx) { | |||
| 285 | const auto setting_name_buf{ctx.ReadBuffer(1)}; | 468 | const auto setting_name_buf{ctx.ReadBuffer(1)}; |
| 286 | const std::string setting_name{setting_name_buf.begin(), setting_name_buf.end()}; | 469 | const std::string setting_name{setting_name_buf.begin(), setting_name_buf.end()}; |
| 287 | 470 | ||
| 288 | auto settings{GetSettings()}; | 471 | std::vector<u8> value; |
| 289 | Result response{ResultUnknown}; | 472 | auto response = GetSettingsItemValue(value, setting_category, setting_name); |
| 290 | 473 | ||
| 291 | if (settings.contains(setting_category) && settings[setting_category].contains(setting_name)) { | 474 | LOG_INFO(Service_SET, "called. category={}, name={} -- res=0x{:X}", setting_category, |
| 292 | auto setting_value = settings[setting_category][setting_name]; | 475 | setting_name, response.raw); |
| 293 | ctx.WriteBuffer(setting_value.data(), setting_value.size()); | 476 | |
| 294 | response = ResultSuccess; | 477 | ctx.WriteBuffer(value.data(), value.size()); |
| 295 | } | ||
| 296 | 478 | ||
| 297 | IPC::ResponseBuilder rb{ctx, 2}; | 479 | IPC::ResponseBuilder rb{ctx, 2}; |
| 298 | rb.Push(response); | 480 | rb.Push(response); |
| @@ -303,19 +485,23 @@ void SET_SYS::GetTvSettings(HLERequestContext& ctx) { | |||
| 303 | 485 | ||
| 304 | IPC::ResponseBuilder rb{ctx, 10}; | 486 | IPC::ResponseBuilder rb{ctx, 10}; |
| 305 | rb.Push(ResultSuccess); | 487 | rb.Push(ResultSuccess); |
| 306 | rb.PushRaw(tv_settings); | 488 | rb.PushRaw(m_system_settings.tv_settings); |
| 307 | } | 489 | } |
| 308 | 490 | ||
| 309 | void SET_SYS::SetTvSettings(HLERequestContext& ctx) { | 491 | void SET_SYS::SetTvSettings(HLERequestContext& ctx) { |
| 310 | IPC::RequestParser rp{ctx}; | 492 | IPC::RequestParser rp{ctx}; |
| 311 | tv_settings = rp.PopRaw<TvSettings>(); | 493 | m_system_settings.tv_settings = rp.PopRaw<TvSettings>(); |
| 494 | SetSaveNeeded(); | ||
| 312 | 495 | ||
| 313 | LOG_INFO(Service_SET, | 496 | LOG_INFO(Service_SET, |
| 314 | "called, flags={}, cmu_mode={}, constrast_ratio={}, hdmi_content_type={}, " | 497 | "called, flags={}, cmu_mode={}, constrast_ratio={}, hdmi_content_type={}, " |
| 315 | "rgb_range={}, tv_gama={}, tv_resolution={}, tv_underscan={}", | 498 | "rgb_range={}, tv_gama={}, tv_resolution={}, tv_underscan={}", |
| 316 | tv_settings.flags.raw, tv_settings.cmu_mode, tv_settings.constrast_ratio, | 499 | m_system_settings.tv_settings.flags.raw, m_system_settings.tv_settings.cmu_mode, |
| 317 | tv_settings.hdmi_content_type, tv_settings.rgb_range, tv_settings.tv_gama, | 500 | m_system_settings.tv_settings.constrast_ratio, |
| 318 | tv_settings.tv_resolution, tv_settings.tv_underscan); | 501 | m_system_settings.tv_settings.hdmi_content_type, |
| 502 | m_system_settings.tv_settings.rgb_range, m_system_settings.tv_settings.tv_gama, | ||
| 503 | m_system_settings.tv_settings.tv_resolution, | ||
| 504 | m_system_settings.tv_settings.tv_underscan); | ||
| 319 | 505 | ||
| 320 | IPC::ResponseBuilder rb{ctx, 2}; | 506 | IPC::ResponseBuilder rb{ctx, 2}; |
| 321 | rb.Push(ResultSuccess); | 507 | rb.Push(ResultSuccess); |
| @@ -329,16 +515,87 @@ void SET_SYS::GetQuestFlag(HLERequestContext& ctx) { | |||
| 329 | rb.PushEnum(QuestFlag::Retail); | 515 | rb.PushEnum(QuestFlag::Retail); |
| 330 | } | 516 | } |
| 331 | 517 | ||
| 518 | void SET_SYS::GetDeviceTimeZoneLocationName(HLERequestContext& ctx) { | ||
| 519 | LOG_WARNING(Service_SET, "called"); | ||
| 520 | |||
| 521 | Service::Time::TimeZone::LocationName name{}; | ||
| 522 | auto res = GetDeviceTimeZoneLocationName(name); | ||
| 523 | |||
| 524 | IPC::ResponseBuilder rb{ctx, 2 + sizeof(Service::Time::TimeZone::LocationName) / sizeof(u32)}; | ||
| 525 | rb.Push(res); | ||
| 526 | rb.PushRaw<Service::Time::TimeZone::LocationName>(name); | ||
| 527 | } | ||
| 528 | |||
| 529 | void SET_SYS::SetDeviceTimeZoneLocationName(HLERequestContext& ctx) { | ||
| 530 | LOG_WARNING(Service_SET, "called"); | ||
| 531 | |||
| 532 | IPC::RequestParser rp{ctx}; | ||
| 533 | auto name{rp.PopRaw<Service::Time::TimeZone::LocationName>()}; | ||
| 534 | |||
| 535 | auto res = SetDeviceTimeZoneLocationName(name); | ||
| 536 | |||
| 537 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 538 | rb.Push(res); | ||
| 539 | } | ||
| 540 | |||
| 332 | void SET_SYS::SetRegionCode(HLERequestContext& ctx) { | 541 | void SET_SYS::SetRegionCode(HLERequestContext& ctx) { |
| 333 | IPC::RequestParser rp{ctx}; | 542 | IPC::RequestParser rp{ctx}; |
| 334 | region_code = rp.PopEnum<RegionCode>(); | 543 | m_system_settings.region_code = rp.PopEnum<RegionCode>(); |
| 544 | SetSaveNeeded(); | ||
| 335 | 545 | ||
| 336 | LOG_INFO(Service_SET, "called, region_code={}", region_code); | 546 | LOG_INFO(Service_SET, "called, region_code={}", m_system_settings.region_code); |
| 337 | 547 | ||
| 338 | IPC::ResponseBuilder rb{ctx, 2}; | 548 | IPC::ResponseBuilder rb{ctx, 2}; |
| 339 | rb.Push(ResultSuccess); | 549 | rb.Push(ResultSuccess); |
| 340 | } | 550 | } |
| 341 | 551 | ||
| 552 | void SET_SYS::GetNetworkSystemClockContext(HLERequestContext& ctx) { | ||
| 553 | LOG_INFO(Service_SET, "called"); | ||
| 554 | |||
| 555 | Service::Time::Clock::SystemClockContext context{}; | ||
| 556 | auto res = GetNetworkSystemClockContext(context); | ||
| 557 | |||
| 558 | IPC::ResponseBuilder rb{ctx, | ||
| 559 | 2 + sizeof(Service::Time::Clock::SystemClockContext) / sizeof(u32)}; | ||
| 560 | rb.Push(res); | ||
| 561 | rb.PushRaw(context); | ||
| 562 | } | ||
| 563 | |||
| 564 | void SET_SYS::SetNetworkSystemClockContext(HLERequestContext& ctx) { | ||
| 565 | LOG_INFO(Service_SET, "called"); | ||
| 566 | |||
| 567 | IPC::RequestParser rp{ctx}; | ||
| 568 | auto context{rp.PopRaw<Service::Time::Clock::SystemClockContext>()}; | ||
| 569 | |||
| 570 | auto res = SetNetworkSystemClockContext(context); | ||
| 571 | |||
| 572 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 573 | rb.Push(res); | ||
| 574 | } | ||
| 575 | |||
| 576 | void SET_SYS::IsUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx) { | ||
| 577 | LOG_INFO(Service_SET, "called"); | ||
| 578 | |||
| 579 | bool enabled{}; | ||
| 580 | auto res = IsUserSystemClockAutomaticCorrectionEnabled(enabled); | ||
| 581 | |||
| 582 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 583 | rb.Push(res); | ||
| 584 | rb.PushRaw(enabled); | ||
| 585 | } | ||
| 586 | |||
| 587 | void SET_SYS::SetUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx) { | ||
| 588 | LOG_INFO(Service_SET, "called"); | ||
| 589 | |||
| 590 | IPC::RequestParser rp{ctx}; | ||
| 591 | auto enabled{rp.Pop<bool>()}; | ||
| 592 | |||
| 593 | auto res = SetUserSystemClockAutomaticCorrectionEnabled(enabled); | ||
| 594 | |||
| 595 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 596 | rb.Push(res); | ||
| 597 | } | ||
| 598 | |||
| 342 | void SET_SYS::GetPrimaryAlbumStorage(HLERequestContext& ctx) { | 599 | void SET_SYS::GetPrimaryAlbumStorage(HLERequestContext& ctx) { |
| 343 | LOG_WARNING(Service_SET, "(STUBBED) called"); | 600 | LOG_WARNING(Service_SET, "(STUBBED) called"); |
| 344 | 601 | ||
| @@ -352,16 +609,18 @@ void SET_SYS::GetSleepSettings(HLERequestContext& ctx) { | |||
| 352 | 609 | ||
| 353 | IPC::ResponseBuilder rb{ctx, 5}; | 610 | IPC::ResponseBuilder rb{ctx, 5}; |
| 354 | rb.Push(ResultSuccess); | 611 | rb.Push(ResultSuccess); |
| 355 | rb.PushRaw(sleep_settings); | 612 | rb.PushRaw(m_system_settings.sleep_settings); |
| 356 | } | 613 | } |
| 357 | 614 | ||
| 358 | void SET_SYS::SetSleepSettings(HLERequestContext& ctx) { | 615 | void SET_SYS::SetSleepSettings(HLERequestContext& ctx) { |
| 359 | IPC::RequestParser rp{ctx}; | 616 | IPC::RequestParser rp{ctx}; |
| 360 | sleep_settings = rp.PopRaw<SleepSettings>(); | 617 | m_system_settings.sleep_settings = rp.PopRaw<SleepSettings>(); |
| 618 | SetSaveNeeded(); | ||
| 361 | 619 | ||
| 362 | LOG_INFO(Service_SET, "called, flags={}, handheld_sleep_plan={}, console_sleep_plan={}", | 620 | LOG_INFO(Service_SET, "called, flags={}, handheld_sleep_plan={}, console_sleep_plan={}", |
| 363 | sleep_settings.flags.raw, sleep_settings.handheld_sleep_plan, | 621 | m_system_settings.sleep_settings.flags.raw, |
| 364 | sleep_settings.console_sleep_plan); | 622 | m_system_settings.sleep_settings.handheld_sleep_plan, |
| 623 | m_system_settings.sleep_settings.console_sleep_plan); | ||
| 365 | 624 | ||
| 366 | IPC::ResponseBuilder rb{ctx, 2}; | 625 | IPC::ResponseBuilder rb{ctx, 2}; |
| 367 | rb.Push(ResultSuccess); | 626 | rb.Push(ResultSuccess); |
| @@ -371,15 +630,20 @@ void SET_SYS::GetInitialLaunchSettings(HLERequestContext& ctx) { | |||
| 371 | LOG_INFO(Service_SET, "called"); | 630 | LOG_INFO(Service_SET, "called"); |
| 372 | IPC::ResponseBuilder rb{ctx, 10}; | 631 | IPC::ResponseBuilder rb{ctx, 10}; |
| 373 | rb.Push(ResultSuccess); | 632 | rb.Push(ResultSuccess); |
| 374 | rb.PushRaw(launch_settings); | 633 | rb.PushRaw(m_system_settings.initial_launch_settings_packed); |
| 375 | } | 634 | } |
| 376 | 635 | ||
| 377 | void SET_SYS::SetInitialLaunchSettings(HLERequestContext& ctx) { | 636 | void SET_SYS::SetInitialLaunchSettings(HLERequestContext& ctx) { |
| 378 | IPC::RequestParser rp{ctx}; | 637 | IPC::RequestParser rp{ctx}; |
| 379 | launch_settings = rp.PopRaw<InitialLaunchSettings>(); | 638 | auto inital_launch_settings = rp.PopRaw<InitialLaunchSettings>(); |
| 380 | 639 | ||
| 381 | LOG_INFO(Service_SET, "called, flags={}, timestamp={}", launch_settings.flags.raw, | 640 | m_system_settings.initial_launch_settings_packed.flags = inital_launch_settings.flags; |
| 382 | launch_settings.timestamp.time_point); | 641 | m_system_settings.initial_launch_settings_packed.timestamp = inital_launch_settings.timestamp; |
| 642 | SetSaveNeeded(); | ||
| 643 | |||
| 644 | LOG_INFO(Service_SET, "called, flags={}, timestamp={}", | ||
| 645 | m_system_settings.initial_launch_settings_packed.flags.raw, | ||
| 646 | m_system_settings.initial_launch_settings_packed.timestamp.time_point); | ||
| 383 | 647 | ||
| 384 | IPC::ResponseBuilder rb{ctx, 2}; | 648 | IPC::ResponseBuilder rb{ctx, 2}; |
| 385 | rb.Push(ResultSuccess); | 649 | rb.Push(ResultSuccess); |
| @@ -437,13 +701,37 @@ void SET_SYS::GetAutoUpdateEnableFlag(HLERequestContext& ctx) { | |||
| 437 | void SET_SYS::GetBatteryPercentageFlag(HLERequestContext& ctx) { | 701 | void SET_SYS::GetBatteryPercentageFlag(HLERequestContext& ctx) { |
| 438 | u8 battery_percentage_flag{1}; | 702 | u8 battery_percentage_flag{1}; |
| 439 | 703 | ||
| 440 | LOG_DEBUG(Service_SET, "(STUBBED) called, battery_percentage_flag={}", battery_percentage_flag); | 704 | LOG_WARNING(Service_SET, "(STUBBED) called, battery_percentage_flag={}", |
| 705 | battery_percentage_flag); | ||
| 441 | 706 | ||
| 442 | IPC::ResponseBuilder rb{ctx, 3}; | 707 | IPC::ResponseBuilder rb{ctx, 3}; |
| 443 | rb.Push(ResultSuccess); | 708 | rb.Push(ResultSuccess); |
| 444 | rb.Push(battery_percentage_flag); | 709 | rb.Push(battery_percentage_flag); |
| 445 | } | 710 | } |
| 446 | 711 | ||
| 712 | void SET_SYS::SetExternalSteadyClockInternalOffset(HLERequestContext& ctx) { | ||
| 713 | LOG_DEBUG(Service_SET, "called."); | ||
| 714 | |||
| 715 | IPC::RequestParser rp{ctx}; | ||
| 716 | auto offset{rp.Pop<s64>()}; | ||
| 717 | |||
| 718 | auto res = SetExternalSteadyClockInternalOffset(offset); | ||
| 719 | |||
| 720 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 721 | rb.Push(res); | ||
| 722 | } | ||
| 723 | |||
| 724 | void SET_SYS::GetExternalSteadyClockInternalOffset(HLERequestContext& ctx) { | ||
| 725 | LOG_DEBUG(Service_SET, "called."); | ||
| 726 | |||
| 727 | s64 offset{}; | ||
| 728 | auto res = GetExternalSteadyClockInternalOffset(offset); | ||
| 729 | |||
| 730 | IPC::ResponseBuilder rb{ctx, 4}; | ||
| 731 | rb.Push(res); | ||
| 732 | rb.Push(offset); | ||
| 733 | } | ||
| 734 | |||
| 447 | void SET_SYS::GetErrorReportSharePermission(HLERequestContext& ctx) { | 735 | void SET_SYS::GetErrorReportSharePermission(HLERequestContext& ctx) { |
| 448 | LOG_WARNING(Service_SET, "(STUBBED) called"); | 736 | LOG_WARNING(Service_SET, "(STUBBED) called"); |
| 449 | 737 | ||
| @@ -453,18 +741,19 @@ void SET_SYS::GetErrorReportSharePermission(HLERequestContext& ctx) { | |||
| 453 | } | 741 | } |
| 454 | 742 | ||
| 455 | void SET_SYS::GetAppletLaunchFlags(HLERequestContext& ctx) { | 743 | void SET_SYS::GetAppletLaunchFlags(HLERequestContext& ctx) { |
| 456 | LOG_INFO(Service_SET, "called, applet_launch_flag={}", applet_launch_flag); | 744 | LOG_INFO(Service_SET, "called, applet_launch_flag={}", m_system_settings.applet_launch_flag); |
| 457 | 745 | ||
| 458 | IPC::ResponseBuilder rb{ctx, 3}; | 746 | IPC::ResponseBuilder rb{ctx, 3}; |
| 459 | rb.Push(ResultSuccess); | 747 | rb.Push(ResultSuccess); |
| 460 | rb.Push(applet_launch_flag); | 748 | rb.Push(m_system_settings.applet_launch_flag); |
| 461 | } | 749 | } |
| 462 | 750 | ||
| 463 | void SET_SYS::SetAppletLaunchFlags(HLERequestContext& ctx) { | 751 | void SET_SYS::SetAppletLaunchFlags(HLERequestContext& ctx) { |
| 464 | IPC::RequestParser rp{ctx}; | 752 | IPC::RequestParser rp{ctx}; |
| 465 | applet_launch_flag = rp.Pop<u32>(); | 753 | m_system_settings.applet_launch_flag = rp.Pop<u32>(); |
| 754 | SetSaveNeeded(); | ||
| 466 | 755 | ||
| 467 | LOG_INFO(Service_SET, "called, applet_launch_flag={}", applet_launch_flag); | 756 | LOG_INFO(Service_SET, "called, applet_launch_flag={}", m_system_settings.applet_launch_flag); |
| 468 | 757 | ||
| 469 | IPC::ResponseBuilder rb{ctx, 2}; | 758 | IPC::ResponseBuilder rb{ctx, 2}; |
| 470 | rb.Push(ResultSuccess); | 759 | rb.Push(ResultSuccess); |
| @@ -489,6 +778,52 @@ void SET_SYS::GetKeyboardLayout(HLERequestContext& ctx) { | |||
| 489 | rb.Push(static_cast<u32>(selected_keyboard_layout)); | 778 | rb.Push(static_cast<u32>(selected_keyboard_layout)); |
| 490 | } | 779 | } |
| 491 | 780 | ||
| 781 | void SET_SYS::GetDeviceTimeZoneLocationUpdatedTime(HLERequestContext& ctx) { | ||
| 782 | LOG_WARNING(Service_SET, "called."); | ||
| 783 | |||
| 784 | Service::Time::Clock::SteadyClockTimePoint time_point{}; | ||
| 785 | auto res = GetDeviceTimeZoneLocationUpdatedTime(time_point); | ||
| 786 | |||
| 787 | IPC::ResponseBuilder rb{ctx, 4}; | ||
| 788 | rb.Push(res); | ||
| 789 | rb.PushRaw<Service::Time::Clock::SteadyClockTimePoint>(time_point); | ||
| 790 | } | ||
| 791 | |||
| 792 | void SET_SYS::SetDeviceTimeZoneLocationUpdatedTime(HLERequestContext& ctx) { | ||
| 793 | LOG_WARNING(Service_SET, "called."); | ||
| 794 | |||
| 795 | IPC::RequestParser rp{ctx}; | ||
| 796 | auto time_point{rp.PopRaw<Service::Time::Clock::SteadyClockTimePoint>()}; | ||
| 797 | |||
| 798 | auto res = SetDeviceTimeZoneLocationUpdatedTime(time_point); | ||
| 799 | |||
| 800 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 801 | rb.Push(res); | ||
| 802 | } | ||
| 803 | |||
| 804 | void SET_SYS::GetUserSystemClockAutomaticCorrectionUpdatedTime(HLERequestContext& ctx) { | ||
| 805 | LOG_WARNING(Service_SET, "called."); | ||
| 806 | |||
| 807 | Service::Time::Clock::SteadyClockTimePoint time_point{}; | ||
| 808 | auto res = GetUserSystemClockAutomaticCorrectionUpdatedTime(time_point); | ||
| 809 | |||
| 810 | IPC::ResponseBuilder rb{ctx, 4}; | ||
| 811 | rb.Push(res); | ||
| 812 | rb.PushRaw<Service::Time::Clock::SteadyClockTimePoint>(time_point); | ||
| 813 | } | ||
| 814 | |||
| 815 | void SET_SYS::SetUserSystemClockAutomaticCorrectionUpdatedTime(HLERequestContext& ctx) { | ||
| 816 | LOG_WARNING(Service_SET, "called."); | ||
| 817 | |||
| 818 | IPC::RequestParser rp{ctx}; | ||
| 819 | auto time_point{rp.PopRaw<Service::Time::Clock::SteadyClockTimePoint>()}; | ||
| 820 | |||
| 821 | auto res = SetUserSystemClockAutomaticCorrectionUpdatedTime(time_point); | ||
| 822 | |||
| 823 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 824 | rb.Push(res); | ||
| 825 | } | ||
| 826 | |||
| 492 | void SET_SYS::GetChineseTraditionalInputMethod(HLERequestContext& ctx) { | 827 | void SET_SYS::GetChineseTraditionalInputMethod(HLERequestContext& ctx) { |
| 493 | LOG_WARNING(Service_SET, "(STUBBED) called"); | 828 | LOG_WARNING(Service_SET, "(STUBBED) called"); |
| 494 | 829 | ||
| @@ -508,7 +843,7 @@ void SET_SYS::GetHomeMenuScheme(HLERequestContext& ctx) { | |||
| 508 | .extra = 0xFF000000, | 843 | .extra = 0xFF000000, |
| 509 | }; | 844 | }; |
| 510 | 845 | ||
| 511 | IPC::ResponseBuilder rb{ctx, 7}; | 846 | IPC::ResponseBuilder rb{ctx, 2 + sizeof(HomeMenuScheme) / sizeof(u32)}; |
| 512 | rb.Push(ResultSuccess); | 847 | rb.Push(ResultSuccess); |
| 513 | rb.PushRaw(default_color); | 848 | rb.PushRaw(default_color); |
| 514 | } | 849 | } |
| @@ -520,6 +855,7 @@ void SET_SYS::GetHomeMenuSchemeModel(HLERequestContext& ctx) { | |||
| 520 | rb.Push(ResultSuccess); | 855 | rb.Push(ResultSuccess); |
| 521 | rb.Push(0); | 856 | rb.Push(0); |
| 522 | } | 857 | } |
| 858 | |||
| 523 | void SET_SYS::GetFieldTestingFlag(HLERequestContext& ctx) { | 859 | void SET_SYS::GetFieldTestingFlag(HLERequestContext& ctx) { |
| 524 | LOG_WARNING(Service_SET, "(STUBBED) called"); | 860 | LOG_WARNING(Service_SET, "(STUBBED) called"); |
| 525 | 861 | ||
| @@ -528,7 +864,7 @@ void SET_SYS::GetFieldTestingFlag(HLERequestContext& ctx) { | |||
| 528 | rb.Push<u8>(false); | 864 | rb.Push<u8>(false); |
| 529 | } | 865 | } |
| 530 | 866 | ||
| 531 | SET_SYS::SET_SYS(Core::System& system_) : ServiceFramework{system_, "set:sys"} { | 867 | SET_SYS::SET_SYS(Core::System& system_) : ServiceFramework{system_, "set:sys"}, m_system{system} { |
| 532 | // clang-format off | 868 | // clang-format off |
| 533 | static const FunctionInfo functions[] = { | 869 | static const FunctionInfo functions[] = { |
| 534 | {0, &SET_SYS::SetLanguageCode, "SetLanguageCode"}, | 870 | {0, &SET_SYS::SetLanguageCode, "SetLanguageCode"}, |
| @@ -543,10 +879,10 @@ SET_SYS::SET_SYS(Core::System& system_) : ServiceFramework{system_, "set:sys"} { | |||
| 543 | {10, nullptr, "SetBacklightSettings"}, | 879 | {10, nullptr, "SetBacklightSettings"}, |
| 544 | {11, nullptr, "SetBluetoothDevicesSettings"}, | 880 | {11, nullptr, "SetBluetoothDevicesSettings"}, |
| 545 | {12, nullptr, "GetBluetoothDevicesSettings"}, | 881 | {12, nullptr, "GetBluetoothDevicesSettings"}, |
| 546 | {13, nullptr, "GetExternalSteadyClockSourceId"}, | 882 | {13, &SET_SYS::GetExternalSteadyClockSourceId, "GetExternalSteadyClockSourceId"}, |
| 547 | {14, nullptr, "SetExternalSteadyClockSourceId"}, | 883 | {14, &SET_SYS::SetExternalSteadyClockSourceId, "SetExternalSteadyClockSourceId"}, |
| 548 | {15, nullptr, "GetUserSystemClockContext"}, | 884 | {15, &SET_SYS::GetUserSystemClockContext, "GetUserSystemClockContext"}, |
| 549 | {16, nullptr, "SetUserSystemClockContext"}, | 885 | {16, &SET_SYS::SetUserSystemClockContext, "SetUserSystemClockContext"}, |
| 550 | {17, &SET_SYS::GetAccountSettings, "GetAccountSettings"}, | 886 | {17, &SET_SYS::GetAccountSettings, "GetAccountSettings"}, |
| 551 | {18, &SET_SYS::SetAccountSettings, "SetAccountSettings"}, | 887 | {18, &SET_SYS::SetAccountSettings, "SetAccountSettings"}, |
| 552 | {19, nullptr, "GetAudioVolume"}, | 888 | {19, nullptr, "GetAudioVolume"}, |
| @@ -581,15 +917,15 @@ SET_SYS::SET_SYS(Core::System& system_) : ServiceFramework{system_, "set:sys"} { | |||
| 581 | {50, nullptr, "SetDataDeletionSettings"}, | 917 | {50, nullptr, "SetDataDeletionSettings"}, |
| 582 | {51, nullptr, "GetInitialSystemAppletProgramId"}, | 918 | {51, nullptr, "GetInitialSystemAppletProgramId"}, |
| 583 | {52, nullptr, "GetOverlayDispProgramId"}, | 919 | {52, nullptr, "GetOverlayDispProgramId"}, |
| 584 | {53, nullptr, "GetDeviceTimeZoneLocationName"}, | 920 | {53, &SET_SYS::GetDeviceTimeZoneLocationName, "GetDeviceTimeZoneLocationName"}, |
| 585 | {54, nullptr, "SetDeviceTimeZoneLocationName"}, | 921 | {54, &SET_SYS::SetDeviceTimeZoneLocationName, "SetDeviceTimeZoneLocationName"}, |
| 586 | {55, nullptr, "GetWirelessCertificationFileSize"}, | 922 | {55, nullptr, "GetWirelessCertificationFileSize"}, |
| 587 | {56, nullptr, "GetWirelessCertificationFile"}, | 923 | {56, nullptr, "GetWirelessCertificationFile"}, |
| 588 | {57, &SET_SYS::SetRegionCode, "SetRegionCode"}, | 924 | {57, &SET_SYS::SetRegionCode, "SetRegionCode"}, |
| 589 | {58, nullptr, "GetNetworkSystemClockContext"}, | 925 | {58, &SET_SYS::GetNetworkSystemClockContext, "GetNetworkSystemClockContext"}, |
| 590 | {59, nullptr, "SetNetworkSystemClockContext"}, | 926 | {59, &SET_SYS::SetNetworkSystemClockContext, "SetNetworkSystemClockContext"}, |
| 591 | {60, nullptr, "IsUserSystemClockAutomaticCorrectionEnabled"}, | 927 | {60, &SET_SYS::IsUserSystemClockAutomaticCorrectionEnabled, "IsUserSystemClockAutomaticCorrectionEnabled"}, |
| 592 | {61, nullptr, "SetUserSystemClockAutomaticCorrectionEnabled"}, | 928 | {61, &SET_SYS::SetUserSystemClockAutomaticCorrectionEnabled, "SetUserSystemClockAutomaticCorrectionEnabled"}, |
| 593 | {62, nullptr, "GetDebugModeFlag"}, | 929 | {62, nullptr, "GetDebugModeFlag"}, |
| 594 | {63, &SET_SYS::GetPrimaryAlbumStorage, "GetPrimaryAlbumStorage"}, | 930 | {63, &SET_SYS::GetPrimaryAlbumStorage, "GetPrimaryAlbumStorage"}, |
| 595 | {64, nullptr, "SetPrimaryAlbumStorage"}, | 931 | {64, nullptr, "SetPrimaryAlbumStorage"}, |
| @@ -633,8 +969,8 @@ SET_SYS::SET_SYS(Core::System& system_) : ServiceFramework{system_, "set:sys"} { | |||
| 633 | {102, nullptr, "SetExternalRtcResetFlag"}, | 969 | {102, nullptr, "SetExternalRtcResetFlag"}, |
| 634 | {103, nullptr, "GetUsbFullKeyEnableFlag"}, | 970 | {103, nullptr, "GetUsbFullKeyEnableFlag"}, |
| 635 | {104, nullptr, "SetUsbFullKeyEnableFlag"}, | 971 | {104, nullptr, "SetUsbFullKeyEnableFlag"}, |
| 636 | {105, nullptr, "SetExternalSteadyClockInternalOffset"}, | 972 | {105, &SET_SYS::SetExternalSteadyClockInternalOffset, "SetExternalSteadyClockInternalOffset"}, |
| 637 | {106, nullptr, "GetExternalSteadyClockInternalOffset"}, | 973 | {106, &SET_SYS::GetExternalSteadyClockInternalOffset, "GetExternalSteadyClockInternalOffset"}, |
| 638 | {107, nullptr, "GetBacklightSettingsEx"}, | 974 | {107, nullptr, "GetBacklightSettingsEx"}, |
| 639 | {108, nullptr, "SetBacklightSettingsEx"}, | 975 | {108, nullptr, "SetBacklightSettingsEx"}, |
| 640 | {109, nullptr, "GetHeadphoneVolumeWarningCount"}, | 976 | {109, nullptr, "GetHeadphoneVolumeWarningCount"}, |
| @@ -678,10 +1014,10 @@ SET_SYS::SET_SYS(Core::System& system_) : ServiceFramework{system_, "set:sys"} { | |||
| 678 | {147, nullptr, "GetConsoleSixAxisSensorAngularAcceleration"}, | 1014 | {147, nullptr, "GetConsoleSixAxisSensorAngularAcceleration"}, |
| 679 | {148, nullptr, "SetConsoleSixAxisSensorAngularAcceleration"}, | 1015 | {148, nullptr, "SetConsoleSixAxisSensorAngularAcceleration"}, |
| 680 | {149, nullptr, "GetRebootlessSystemUpdateVersion"}, | 1016 | {149, nullptr, "GetRebootlessSystemUpdateVersion"}, |
| 681 | {150, nullptr, "GetDeviceTimeZoneLocationUpdatedTime"}, | 1017 | {150, &SET_SYS::GetDeviceTimeZoneLocationUpdatedTime, "GetDeviceTimeZoneLocationUpdatedTime"}, |
| 682 | {151, nullptr, "SetDeviceTimeZoneLocationUpdatedTime"}, | 1018 | {151, &SET_SYS::SetDeviceTimeZoneLocationUpdatedTime, "SetDeviceTimeZoneLocationUpdatedTime"}, |
| 683 | {152, nullptr, "GetUserSystemClockAutomaticCorrectionUpdatedTime"}, | 1019 | {152, &SET_SYS::GetUserSystemClockAutomaticCorrectionUpdatedTime, "GetUserSystemClockAutomaticCorrectionUpdatedTime"}, |
| 684 | {153, nullptr, "SetUserSystemClockAutomaticCorrectionUpdatedTime"}, | 1020 | {153, &SET_SYS::SetUserSystemClockAutomaticCorrectionUpdatedTime, "SetUserSystemClockAutomaticCorrectionUpdatedTime"}, |
| 685 | {154, nullptr, "GetAccountOnlineStorageSettings"}, | 1021 | {154, nullptr, "GetAccountOnlineStorageSettings"}, |
| 686 | {155, nullptr, "SetAccountOnlineStorageSettings"}, | 1022 | {155, nullptr, "SetAccountOnlineStorageSettings"}, |
| 687 | {156, nullptr, "GetPctlReadyFlag"}, | 1023 | {156, nullptr, "GetPctlReadyFlag"}, |
| @@ -743,8 +1079,184 @@ SET_SYS::SET_SYS(Core::System& system_) : ServiceFramework{system_, "set:sys"} { | |||
| 743 | // clang-format on | 1079 | // clang-format on |
| 744 | 1080 | ||
| 745 | RegisterHandlers(functions); | 1081 | RegisterHandlers(functions); |
| 1082 | |||
| 1083 | SetupSettings(); | ||
| 1084 | m_save_thread = | ||
| 1085 | std::jthread([this](std::stop_token stop_token) { StoreSettingsThreadFunc(stop_token); }); | ||
| 1086 | } | ||
| 1087 | |||
| 1088 | SET_SYS::~SET_SYS() { | ||
| 1089 | SetSaveNeeded(); | ||
| 1090 | m_save_thread.request_stop(); | ||
| 1091 | } | ||
| 1092 | |||
| 1093 | void SET_SYS::SetupSettings() { | ||
| 1094 | auto system_dir = | ||
| 1095 | Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000050"; | ||
| 1096 | if (!LoadSettingsFile(system_dir, []() { return DefaultSystemSettings(); })) { | ||
| 1097 | ASSERT(false); | ||
| 1098 | } | ||
| 1099 | |||
| 1100 | auto private_dir = | ||
| 1101 | Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000052"; | ||
| 1102 | if (!LoadSettingsFile(private_dir, []() { return DefaultPrivateSettings(); })) { | ||
| 1103 | ASSERT(false); | ||
| 1104 | } | ||
| 1105 | |||
| 1106 | auto device_dir = | ||
| 1107 | Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000053"; | ||
| 1108 | if (!LoadSettingsFile(device_dir, []() { return DefaultDeviceSettings(); })) { | ||
| 1109 | ASSERT(false); | ||
| 1110 | } | ||
| 1111 | |||
| 1112 | auto appln_dir = | ||
| 1113 | Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000054"; | ||
| 1114 | if (!LoadSettingsFile(appln_dir, []() { return DefaultApplnSettings(); })) { | ||
| 1115 | ASSERT(false); | ||
| 1116 | } | ||
| 1117 | } | ||
| 1118 | |||
| 1119 | void SET_SYS::StoreSettings() { | ||
| 1120 | auto system_dir = | ||
| 1121 | Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000050"; | ||
| 1122 | if (!StoreSettingsFile(system_dir, m_system_settings)) { | ||
| 1123 | LOG_ERROR(HW_GPU, "Failed to store System settings"); | ||
| 1124 | } | ||
| 1125 | |||
| 1126 | auto private_dir = | ||
| 1127 | Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000052"; | ||
| 1128 | if (!StoreSettingsFile(private_dir, m_private_settings)) { | ||
| 1129 | LOG_ERROR(HW_GPU, "Failed to store Private settings"); | ||
| 1130 | } | ||
| 1131 | |||
| 1132 | auto device_dir = | ||
| 1133 | Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000053"; | ||
| 1134 | if (!StoreSettingsFile(device_dir, m_device_settings)) { | ||
| 1135 | LOG_ERROR(HW_GPU, "Failed to store Device settings"); | ||
| 1136 | } | ||
| 1137 | |||
| 1138 | auto appln_dir = | ||
| 1139 | Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000054"; | ||
| 1140 | if (!StoreSettingsFile(appln_dir, m_appln_settings)) { | ||
| 1141 | LOG_ERROR(HW_GPU, "Failed to store ApplLn settings"); | ||
| 1142 | } | ||
| 1143 | } | ||
| 1144 | |||
| 1145 | void SET_SYS::StoreSettingsThreadFunc(std::stop_token stop_token) { | ||
| 1146 | while (Common::StoppableTimedWait(stop_token, std::chrono::minutes(1))) { | ||
| 1147 | std::scoped_lock l{m_save_needed_mutex}; | ||
| 1148 | if (!std::exchange(m_save_needed, false)) { | ||
| 1149 | continue; | ||
| 1150 | } | ||
| 1151 | StoreSettings(); | ||
| 1152 | } | ||
| 1153 | } | ||
| 1154 | |||
| 1155 | void SET_SYS::SetSaveNeeded() { | ||
| 1156 | std::scoped_lock l{m_save_needed_mutex}; | ||
| 1157 | m_save_needed = true; | ||
| 1158 | } | ||
| 1159 | |||
| 1160 | Result SET_SYS::GetSettingsItemValue(std::vector<u8>& out_value, const std::string& category, | ||
| 1161 | const std::string& name) { | ||
| 1162 | auto settings{GetSettings()}; | ||
| 1163 | R_UNLESS(settings.contains(category) && settings[category].contains(name), ResultUnknown); | ||
| 1164 | |||
| 1165 | out_value = settings[category][name]; | ||
| 1166 | R_SUCCEED(); | ||
| 1167 | } | ||
| 1168 | |||
| 1169 | Result SET_SYS::GetExternalSteadyClockSourceId(Common::UUID& out_id) { | ||
| 1170 | out_id = m_private_settings.external_clock_source_id; | ||
| 1171 | R_SUCCEED(); | ||
| 1172 | } | ||
| 1173 | |||
| 1174 | Result SET_SYS::SetExternalSteadyClockSourceId(Common::UUID id) { | ||
| 1175 | m_private_settings.external_clock_source_id = id; | ||
| 1176 | SetSaveNeeded(); | ||
| 1177 | R_SUCCEED(); | ||
| 1178 | } | ||
| 1179 | |||
| 1180 | Result SET_SYS::GetUserSystemClockContext(Service::Time::Clock::SystemClockContext& out_context) { | ||
| 1181 | out_context = m_system_settings.user_system_clock_context; | ||
| 1182 | R_SUCCEED(); | ||
| 746 | } | 1183 | } |
| 747 | 1184 | ||
| 748 | SET_SYS::~SET_SYS() = default; | 1185 | Result SET_SYS::SetUserSystemClockContext(Service::Time::Clock::SystemClockContext& context) { |
| 1186 | m_system_settings.user_system_clock_context = context; | ||
| 1187 | SetSaveNeeded(); | ||
| 1188 | R_SUCCEED(); | ||
| 1189 | } | ||
| 1190 | |||
| 1191 | Result SET_SYS::GetDeviceTimeZoneLocationName(Service::Time::TimeZone::LocationName& out_name) { | ||
| 1192 | out_name = m_system_settings.device_time_zone_location_name; | ||
| 1193 | R_SUCCEED(); | ||
| 1194 | } | ||
| 1195 | |||
| 1196 | Result SET_SYS::SetDeviceTimeZoneLocationName(Service::Time::TimeZone::LocationName& name) { | ||
| 1197 | m_system_settings.device_time_zone_location_name = name; | ||
| 1198 | SetSaveNeeded(); | ||
| 1199 | R_SUCCEED(); | ||
| 1200 | } | ||
| 1201 | |||
| 1202 | Result SET_SYS::GetNetworkSystemClockContext( | ||
| 1203 | Service::Time::Clock::SystemClockContext& out_context) { | ||
| 1204 | out_context = m_system_settings.network_system_clock_context; | ||
| 1205 | R_SUCCEED(); | ||
| 1206 | } | ||
| 1207 | |||
| 1208 | Result SET_SYS::SetNetworkSystemClockContext(Service::Time::Clock::SystemClockContext& context) { | ||
| 1209 | m_system_settings.network_system_clock_context = context; | ||
| 1210 | SetSaveNeeded(); | ||
| 1211 | R_SUCCEED(); | ||
| 1212 | } | ||
| 1213 | |||
| 1214 | Result SET_SYS::IsUserSystemClockAutomaticCorrectionEnabled(bool& out_enabled) { | ||
| 1215 | out_enabled = m_system_settings.user_system_clock_automatic_correction_enabled; | ||
| 1216 | R_SUCCEED(); | ||
| 1217 | } | ||
| 1218 | |||
| 1219 | Result SET_SYS::SetUserSystemClockAutomaticCorrectionEnabled(bool enabled) { | ||
| 1220 | m_system_settings.user_system_clock_automatic_correction_enabled = enabled; | ||
| 1221 | SetSaveNeeded(); | ||
| 1222 | R_SUCCEED(); | ||
| 1223 | } | ||
| 1224 | |||
| 1225 | Result SET_SYS::SetExternalSteadyClockInternalOffset(s64 offset) { | ||
| 1226 | m_private_settings.external_steady_clock_internal_offset = offset; | ||
| 1227 | SetSaveNeeded(); | ||
| 1228 | R_SUCCEED(); | ||
| 1229 | } | ||
| 1230 | |||
| 1231 | Result SET_SYS::GetExternalSteadyClockInternalOffset(s64& out_offset) { | ||
| 1232 | out_offset = m_private_settings.external_steady_clock_internal_offset; | ||
| 1233 | R_SUCCEED(); | ||
| 1234 | } | ||
| 1235 | |||
| 1236 | Result SET_SYS::GetDeviceTimeZoneLocationUpdatedTime( | ||
| 1237 | Service::Time::Clock::SteadyClockTimePoint& out_time_point) { | ||
| 1238 | out_time_point = m_system_settings.device_time_zone_location_updated_time; | ||
| 1239 | R_SUCCEED(); | ||
| 1240 | } | ||
| 1241 | |||
| 1242 | Result SET_SYS::SetDeviceTimeZoneLocationUpdatedTime( | ||
| 1243 | Service::Time::Clock::SteadyClockTimePoint& time_point) { | ||
| 1244 | m_system_settings.device_time_zone_location_updated_time = time_point; | ||
| 1245 | SetSaveNeeded(); | ||
| 1246 | R_SUCCEED(); | ||
| 1247 | } | ||
| 1248 | |||
| 1249 | Result SET_SYS::GetUserSystemClockAutomaticCorrectionUpdatedTime( | ||
| 1250 | Service::Time::Clock::SteadyClockTimePoint& out_time_point) { | ||
| 1251 | out_time_point = m_system_settings.user_system_clock_automatic_correction_updated_time_point; | ||
| 1252 | R_SUCCEED(); | ||
| 1253 | } | ||
| 1254 | |||
| 1255 | Result SET_SYS::SetUserSystemClockAutomaticCorrectionUpdatedTime( | ||
| 1256 | Service::Time::Clock::SteadyClockTimePoint out_time_point) { | ||
| 1257 | m_system_settings.user_system_clock_automatic_correction_updated_time_point = out_time_point; | ||
| 1258 | SetSaveNeeded(); | ||
| 1259 | R_SUCCEED(); | ||
| 1260 | } | ||
| 749 | 1261 | ||
| 750 | } // namespace Service::Set | 1262 | } // namespace Service::Set |
diff --git a/src/core/hle/service/set/set_sys.h b/src/core/hle/service/set/set_sys.h index 5f770fd32..3785d93d8 100644 --- a/src/core/hle/service/set/set_sys.h +++ b/src/core/hle/service/set/set_sys.h | |||
| @@ -3,17 +3,27 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <filesystem> | ||
| 7 | #include <mutex> | ||
| 8 | #include <string> | ||
| 9 | #include <thread> | ||
| 10 | |||
| 11 | #include "common/polyfill_thread.h" | ||
| 6 | #include "common/uuid.h" | 12 | #include "common/uuid.h" |
| 7 | #include "core/hle/result.h" | 13 | #include "core/hle/result.h" |
| 8 | #include "core/hle/service/service.h" | 14 | #include "core/hle/service/service.h" |
| 15 | #include "core/hle/service/set/appln_settings.h" | ||
| 16 | #include "core/hle/service/set/device_settings.h" | ||
| 17 | #include "core/hle/service/set/private_settings.h" | ||
| 18 | #include "core/hle/service/set/system_settings.h" | ||
| 9 | #include "core/hle/service/time/clock_types.h" | 19 | #include "core/hle/service/time/clock_types.h" |
| 20 | #include "core/hle/service/time/time_zone_types.h" | ||
| 10 | 21 | ||
| 11 | namespace Core { | 22 | namespace Core { |
| 12 | class System; | 23 | class System; |
| 13 | } | 24 | } |
| 14 | 25 | ||
| 15 | namespace Service::Set { | 26 | namespace Service::Set { |
| 16 | enum class LanguageCode : u64; | ||
| 17 | enum class GetFirmwareVersionType { | 27 | enum class GetFirmwareVersionType { |
| 18 | Version1, | 28 | Version1, |
| 19 | Version2, | 29 | Version2, |
| @@ -42,270 +52,38 @@ public: | |||
| 42 | explicit SET_SYS(Core::System& system_); | 52 | explicit SET_SYS(Core::System& system_); |
| 43 | ~SET_SYS() override; | 53 | ~SET_SYS() override; |
| 44 | 54 | ||
| 45 | private: | 55 | Result GetSettingsItemValue(std::vector<u8>& out_value, const std::string& category, |
| 46 | /// Indicates the current theme set by the system settings | 56 | const std::string& name); |
| 47 | enum class ColorSet : u32 { | 57 | |
| 48 | BasicWhite = 0, | 58 | Result GetExternalSteadyClockSourceId(Common::UUID& out_id); |
| 49 | BasicBlack = 1, | 59 | Result SetExternalSteadyClockSourceId(Common::UUID id); |
| 50 | }; | 60 | Result GetUserSystemClockContext(Service::Time::Clock::SystemClockContext& out_context); |
| 51 | 61 | Result SetUserSystemClockContext(Service::Time::Clock::SystemClockContext& context); | |
| 52 | /// Indicates the current console is a retail or kiosk unit | 62 | Result GetDeviceTimeZoneLocationName(Service::Time::TimeZone::LocationName& out_name); |
| 53 | enum class QuestFlag : u8 { | 63 | Result SetDeviceTimeZoneLocationName(Service::Time::TimeZone::LocationName& name); |
| 54 | Retail = 0, | 64 | Result GetNetworkSystemClockContext(Service::Time::Clock::SystemClockContext& out_context); |
| 55 | Kiosk = 1, | 65 | Result SetNetworkSystemClockContext(Service::Time::Clock::SystemClockContext& context); |
| 56 | }; | 66 | Result IsUserSystemClockAutomaticCorrectionEnabled(bool& out_enabled); |
| 57 | 67 | Result SetUserSystemClockAutomaticCorrectionEnabled(bool enabled); | |
| 58 | /// This is nn::settings::system::TvResolution | 68 | Result SetExternalSteadyClockInternalOffset(s64 offset); |
| 59 | enum class TvResolution : u32 { | 69 | Result GetExternalSteadyClockInternalOffset(s64& out_offset); |
| 60 | Auto, | 70 | Result GetDeviceTimeZoneLocationUpdatedTime( |
| 61 | Resolution1080p, | 71 | Service::Time::Clock::SteadyClockTimePoint& out_time_point); |
| 62 | Resolution720p, | 72 | Result SetDeviceTimeZoneLocationUpdatedTime( |
| 63 | Resolution480p, | 73 | Service::Time::Clock::SteadyClockTimePoint& time_point); |
| 64 | }; | 74 | Result GetUserSystemClockAutomaticCorrectionUpdatedTime( |
| 65 | 75 | Service::Time::Clock::SteadyClockTimePoint& out_time_point); | |
| 66 | /// This is nn::settings::system::HdmiContentType | 76 | Result SetUserSystemClockAutomaticCorrectionUpdatedTime( |
| 67 | enum class HdmiContentType : u32 { | 77 | Service::Time::Clock::SteadyClockTimePoint time_point); |
| 68 | None, | ||
| 69 | Graphics, | ||
| 70 | Cinema, | ||
| 71 | Photo, | ||
| 72 | Game, | ||
| 73 | }; | ||
| 74 | |||
| 75 | /// This is nn::settings::system::RgbRange | ||
| 76 | enum class RgbRange : u32 { | ||
| 77 | Auto, | ||
| 78 | Full, | ||
| 79 | Limited, | ||
| 80 | }; | ||
| 81 | |||
| 82 | /// This is nn::settings::system::CmuMode | ||
| 83 | enum class CmuMode : u32 { | ||
| 84 | None, | ||
| 85 | ColorInvert, | ||
| 86 | HighContrast, | ||
| 87 | GrayScale, | ||
| 88 | }; | ||
| 89 | |||
| 90 | /// This is nn::settings::system::PrimaryAlbumStorage | ||
| 91 | enum class PrimaryAlbumStorage : u32 { | ||
| 92 | Nand, | ||
| 93 | SdCard, | ||
| 94 | }; | ||
| 95 | |||
| 96 | /// This is nn::settings::system::NotificationVolume | ||
| 97 | enum class NotificationVolume : u32 { | ||
| 98 | Mute, | ||
| 99 | Low, | ||
| 100 | High, | ||
| 101 | }; | ||
| 102 | |||
| 103 | /// This is nn::settings::system::ChineseTraditionalInputMethod | ||
| 104 | enum class ChineseTraditionalInputMethod : u32 { | ||
| 105 | Unknown0 = 0, | ||
| 106 | Unknown1 = 1, | ||
| 107 | Unknown2 = 2, | ||
| 108 | }; | ||
| 109 | |||
| 110 | /// This is nn::settings::system::ErrorReportSharePermission | ||
| 111 | enum class ErrorReportSharePermission : u32 { | ||
| 112 | NotConfirmed, | ||
| 113 | Granted, | ||
| 114 | Denied, | ||
| 115 | }; | ||
| 116 | |||
| 117 | /// This is nn::settings::system::FriendPresenceOverlayPermission | ||
| 118 | enum class FriendPresenceOverlayPermission : u8 { | ||
| 119 | NotConfirmed, | ||
| 120 | NoDisplay, | ||
| 121 | FavoriteFriends, | ||
| 122 | Friends, | ||
| 123 | }; | ||
| 124 | |||
| 125 | /// This is nn::settings::system::HandheldSleepPlan | ||
| 126 | enum class HandheldSleepPlan : u32 { | ||
| 127 | Sleep1Min, | ||
| 128 | Sleep3Min, | ||
| 129 | Sleep5Min, | ||
| 130 | Sleep10Min, | ||
| 131 | Sleep30Min, | ||
| 132 | Never, | ||
| 133 | }; | ||
| 134 | |||
| 135 | /// This is nn::settings::system::ConsoleSleepPlan | ||
| 136 | enum class ConsoleSleepPlan : u32 { | ||
| 137 | Sleep1Hour, | ||
| 138 | Sleep2Hour, | ||
| 139 | Sleep3Hour, | ||
| 140 | Sleep6Hour, | ||
| 141 | Sleep12Hour, | ||
| 142 | Never, | ||
| 143 | }; | ||
| 144 | |||
| 145 | /// This is nn::settings::system::RegionCode | ||
| 146 | enum class RegionCode : u32 { | ||
| 147 | Japan, | ||
| 148 | Usa, | ||
| 149 | Europe, | ||
| 150 | Australia, | ||
| 151 | HongKongTaiwanKorea, | ||
| 152 | China, | ||
| 153 | }; | ||
| 154 | |||
| 155 | /// This is nn::settings::system::EulaVersionClockType | ||
| 156 | enum class EulaVersionClockType : u32 { | ||
| 157 | NetworkSystemClock, | ||
| 158 | SteadyClock, | ||
| 159 | }; | ||
| 160 | |||
| 161 | /// This is nn::settings::system::SleepFlag | ||
| 162 | struct SleepFlag { | ||
| 163 | union { | ||
| 164 | u32 raw{}; | ||
| 165 | |||
| 166 | BitField<0, 1, u32> SleepsWhilePlayingMedia; | ||
| 167 | BitField<1, 1, u32> WakesAtPowerStateChange; | ||
| 168 | }; | ||
| 169 | }; | ||
| 170 | static_assert(sizeof(SleepFlag) == 4, "TvFlag is an invalid size"); | ||
| 171 | |||
| 172 | /// This is nn::settings::system::TvFlag | ||
| 173 | struct TvFlag { | ||
| 174 | union { | ||
| 175 | u32 raw{}; | ||
| 176 | |||
| 177 | BitField<0, 1, u32> Allows4k; | ||
| 178 | BitField<1, 1, u32> Allows3d; | ||
| 179 | BitField<2, 1, u32> AllowsCec; | ||
| 180 | BitField<3, 1, u32> PreventsScreenBurnIn; | ||
| 181 | }; | ||
| 182 | }; | ||
| 183 | static_assert(sizeof(TvFlag) == 4, "TvFlag is an invalid size"); | ||
| 184 | |||
| 185 | /// This is nn::settings::system::InitialLaunchFlag | ||
| 186 | struct InitialLaunchFlag { | ||
| 187 | union { | ||
| 188 | u32 raw{}; | ||
| 189 | |||
| 190 | BitField<0, 1, u32> InitialLaunchCompletionFlag; | ||
| 191 | BitField<8, 1, u32> InitialLaunchUserAdditionFlag; | ||
| 192 | BitField<16, 1, u32> InitialLaunchTimestampFlag; | ||
| 193 | }; | ||
| 194 | }; | ||
| 195 | static_assert(sizeof(InitialLaunchFlag) == 4, "InitialLaunchFlag is an invalid size"); | ||
| 196 | |||
| 197 | /// This is nn::settings::system::NotificationFlag | ||
| 198 | struct NotificationFlag { | ||
| 199 | union { | ||
| 200 | u32 raw{}; | ||
| 201 | |||
| 202 | BitField<0, 1, u32> RingtoneFlag; | ||
| 203 | BitField<1, 1, u32> DownloadCompletionFlag; | ||
| 204 | BitField<8, 1, u32> EnablesNews; | ||
| 205 | BitField<9, 1, u32> IncomingLampFlag; | ||
| 206 | }; | ||
| 207 | }; | ||
| 208 | static_assert(sizeof(NotificationFlag) == 4, "NotificationFlag is an invalid size"); | ||
| 209 | |||
| 210 | /// This is nn::settings::system::AccountNotificationFlag | ||
| 211 | struct AccountNotificationFlag { | ||
| 212 | union { | ||
| 213 | u32 raw{}; | ||
| 214 | |||
| 215 | BitField<0, 1, u32> FriendOnlineFlag; | ||
| 216 | BitField<1, 1, u32> FriendRequestFlag; | ||
| 217 | BitField<8, 1, u32> CoralInvitationFlag; | ||
| 218 | }; | ||
| 219 | }; | ||
| 220 | static_assert(sizeof(AccountNotificationFlag) == 4, | ||
| 221 | "AccountNotificationFlag is an invalid size"); | ||
| 222 | |||
| 223 | /// This is nn::settings::system::TvSettings | ||
| 224 | struct TvSettings { | ||
| 225 | TvFlag flags; | ||
| 226 | TvResolution tv_resolution; | ||
| 227 | HdmiContentType hdmi_content_type; | ||
| 228 | RgbRange rgb_range; | ||
| 229 | CmuMode cmu_mode; | ||
| 230 | u32 tv_underscan; | ||
| 231 | f32 tv_gama; | ||
| 232 | f32 constrast_ratio; | ||
| 233 | }; | ||
| 234 | static_assert(sizeof(TvSettings) == 0x20, "TvSettings is an invalid size"); | ||
| 235 | |||
| 236 | /// This is nn::settings::system::NotificationTime | ||
| 237 | struct NotificationTime { | ||
| 238 | u32 hour; | ||
| 239 | u32 minute; | ||
| 240 | }; | ||
| 241 | static_assert(sizeof(NotificationTime) == 0x8, "NotificationTime is an invalid size"); | ||
| 242 | |||
| 243 | /// This is nn::settings::system::NotificationSettings | ||
| 244 | struct NotificationSettings { | ||
| 245 | NotificationFlag flags; | ||
| 246 | NotificationVolume volume; | ||
| 247 | NotificationTime start_time; | ||
| 248 | NotificationTime stop_time; | ||
| 249 | }; | ||
| 250 | static_assert(sizeof(NotificationSettings) == 0x18, "NotificationSettings is an invalid size"); | ||
| 251 | |||
| 252 | /// This is nn::settings::system::AccountSettings | ||
| 253 | struct AccountSettings { | ||
| 254 | u32 flags; | ||
| 255 | }; | ||
| 256 | static_assert(sizeof(AccountSettings) == 0x4, "AccountSettings is an invalid size"); | ||
| 257 | |||
| 258 | /// This is nn::settings::system::AccountNotificationSettings | ||
| 259 | struct AccountNotificationSettings { | ||
| 260 | Common::UUID uid; | ||
| 261 | AccountNotificationFlag flags; | ||
| 262 | FriendPresenceOverlayPermission friend_presence_permission; | ||
| 263 | FriendPresenceOverlayPermission friend_invitation_permission; | ||
| 264 | INSERT_PADDING_BYTES(0x2); | ||
| 265 | }; | ||
| 266 | static_assert(sizeof(AccountNotificationSettings) == 0x18, | ||
| 267 | "AccountNotificationSettings is an invalid size"); | ||
| 268 | |||
| 269 | /// This is nn::settings::system::InitialLaunchSettings | ||
| 270 | struct SleepSettings { | ||
| 271 | SleepFlag flags; | ||
| 272 | HandheldSleepPlan handheld_sleep_plan; | ||
| 273 | ConsoleSleepPlan console_sleep_plan; | ||
| 274 | }; | ||
| 275 | static_assert(sizeof(SleepSettings) == 0xc, "SleepSettings is incorrect size"); | ||
| 276 | |||
| 277 | /// This is nn::settings::system::InitialLaunchSettings | ||
| 278 | struct InitialLaunchSettings { | ||
| 279 | InitialLaunchFlag flags; | ||
| 280 | INSERT_PADDING_BYTES(0x4); | ||
| 281 | Time::Clock::SteadyClockTimePoint timestamp; | ||
| 282 | }; | ||
| 283 | static_assert(sizeof(InitialLaunchSettings) == 0x20, "InitialLaunchSettings is incorrect size"); | ||
| 284 | |||
| 285 | /// This is nn::settings::system::InitialLaunchSettings | ||
| 286 | struct EulaVersion { | ||
| 287 | u32 version; | ||
| 288 | RegionCode region_code; | ||
| 289 | EulaVersionClockType clock_type; | ||
| 290 | INSERT_PADDING_BYTES(0x4); | ||
| 291 | s64 posix_time; | ||
| 292 | Time::Clock::SteadyClockTimePoint timestamp; | ||
| 293 | }; | ||
| 294 | static_assert(sizeof(EulaVersion) == 0x30, "EulaVersion is incorrect size"); | ||
| 295 | |||
| 296 | /// This is nn::settings::system::HomeMenuScheme | ||
| 297 | struct HomeMenuScheme { | ||
| 298 | u32 main; | ||
| 299 | u32 back; | ||
| 300 | u32 sub; | ||
| 301 | u32 bezel; | ||
| 302 | u32 extra; | ||
| 303 | }; | ||
| 304 | static_assert(sizeof(HomeMenuScheme) == 0x14, "HomeMenuScheme is incorrect size"); | ||
| 305 | 78 | ||
| 79 | private: | ||
| 306 | void SetLanguageCode(HLERequestContext& ctx); | 80 | void SetLanguageCode(HLERequestContext& ctx); |
| 307 | void GetFirmwareVersion(HLERequestContext& ctx); | 81 | void GetFirmwareVersion(HLERequestContext& ctx); |
| 308 | void GetFirmwareVersion2(HLERequestContext& ctx); | 82 | void GetFirmwareVersion2(HLERequestContext& ctx); |
| 83 | void GetExternalSteadyClockSourceId(HLERequestContext& ctx); | ||
| 84 | void SetExternalSteadyClockSourceId(HLERequestContext& ctx); | ||
| 85 | void GetUserSystemClockContext(HLERequestContext& ctx); | ||
| 86 | void SetUserSystemClockContext(HLERequestContext& ctx); | ||
| 309 | void GetAccountSettings(HLERequestContext& ctx); | 87 | void GetAccountSettings(HLERequestContext& ctx); |
| 310 | void SetAccountSettings(HLERequestContext& ctx); | 88 | void SetAccountSettings(HLERequestContext& ctx); |
| 311 | void GetEulaVersions(HLERequestContext& ctx); | 89 | void GetEulaVersions(HLERequestContext& ctx); |
| @@ -321,7 +99,13 @@ private: | |||
| 321 | void GetTvSettings(HLERequestContext& ctx); | 99 | void GetTvSettings(HLERequestContext& ctx); |
| 322 | void SetTvSettings(HLERequestContext& ctx); | 100 | void SetTvSettings(HLERequestContext& ctx); |
| 323 | void GetQuestFlag(HLERequestContext& ctx); | 101 | void GetQuestFlag(HLERequestContext& ctx); |
| 102 | void GetDeviceTimeZoneLocationName(HLERequestContext& ctx); | ||
| 103 | void SetDeviceTimeZoneLocationName(HLERequestContext& ctx); | ||
| 324 | void SetRegionCode(HLERequestContext& ctx); | 104 | void SetRegionCode(HLERequestContext& ctx); |
| 105 | void GetNetworkSystemClockContext(HLERequestContext& ctx); | ||
| 106 | void SetNetworkSystemClockContext(HLERequestContext& ctx); | ||
| 107 | void IsUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx); | ||
| 108 | void SetUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx); | ||
| 325 | void GetPrimaryAlbumStorage(HLERequestContext& ctx); | 109 | void GetPrimaryAlbumStorage(HLERequestContext& ctx); |
| 326 | void GetSleepSettings(HLERequestContext& ctx); | 110 | void GetSleepSettings(HLERequestContext& ctx); |
| 327 | void SetSleepSettings(HLERequestContext& ctx); | 111 | void SetSleepSettings(HLERequestContext& ctx); |
| @@ -333,59 +117,36 @@ private: | |||
| 333 | void GetMiiAuthorId(HLERequestContext& ctx); | 117 | void GetMiiAuthorId(HLERequestContext& ctx); |
| 334 | void GetAutoUpdateEnableFlag(HLERequestContext& ctx); | 118 | void GetAutoUpdateEnableFlag(HLERequestContext& ctx); |
| 335 | void GetBatteryPercentageFlag(HLERequestContext& ctx); | 119 | void GetBatteryPercentageFlag(HLERequestContext& ctx); |
| 120 | void SetExternalSteadyClockInternalOffset(HLERequestContext& ctx); | ||
| 121 | void GetExternalSteadyClockInternalOffset(HLERequestContext& ctx); | ||
| 336 | void GetErrorReportSharePermission(HLERequestContext& ctx); | 122 | void GetErrorReportSharePermission(HLERequestContext& ctx); |
| 337 | void GetAppletLaunchFlags(HLERequestContext& ctx); | 123 | void GetAppletLaunchFlags(HLERequestContext& ctx); |
| 338 | void SetAppletLaunchFlags(HLERequestContext& ctx); | 124 | void SetAppletLaunchFlags(HLERequestContext& ctx); |
| 339 | void GetKeyboardLayout(HLERequestContext& ctx); | 125 | void GetKeyboardLayout(HLERequestContext& ctx); |
| 126 | void GetDeviceTimeZoneLocationUpdatedTime(HLERequestContext& ctx); | ||
| 127 | void SetDeviceTimeZoneLocationUpdatedTime(HLERequestContext& ctx); | ||
| 128 | void GetUserSystemClockAutomaticCorrectionUpdatedTime(HLERequestContext& ctx); | ||
| 129 | void SetUserSystemClockAutomaticCorrectionUpdatedTime(HLERequestContext& ctx); | ||
| 340 | void GetChineseTraditionalInputMethod(HLERequestContext& ctx); | 130 | void GetChineseTraditionalInputMethod(HLERequestContext& ctx); |
| 341 | void GetFieldTestingFlag(HLERequestContext& ctx); | ||
| 342 | void GetHomeMenuScheme(HLERequestContext& ctx); | 131 | void GetHomeMenuScheme(HLERequestContext& ctx); |
| 343 | void GetHomeMenuSchemeModel(HLERequestContext& ctx); | 132 | void GetHomeMenuSchemeModel(HLERequestContext& ctx); |
| 133 | void GetFieldTestingFlag(HLERequestContext& ctx); | ||
| 344 | 134 | ||
| 345 | AccountSettings account_settings{ | 135 | bool LoadSettingsFile(std::filesystem::path& path, auto&& default_func); |
| 346 | .flags = {}, | 136 | bool StoreSettingsFile(std::filesystem::path& path, auto& settings); |
| 347 | }; | 137 | void SetupSettings(); |
| 348 | 138 | void StoreSettings(); | |
| 349 | ColorSet color_set = ColorSet::BasicWhite; | 139 | void StoreSettingsThreadFunc(std::stop_token stop_token); |
| 350 | 140 | void SetSaveNeeded(); | |
| 351 | NotificationSettings notification_settings{ | 141 | |
| 352 | .flags = {0x300}, | 142 | Core::System& m_system; |
| 353 | .volume = NotificationVolume::High, | 143 | SystemSettings m_system_settings{}; |
| 354 | .start_time = {.hour = 9, .minute = 0}, | 144 | PrivateSettings m_private_settings{}; |
| 355 | .stop_time = {.hour = 21, .minute = 0}, | 145 | DeviceSettings m_device_settings{}; |
| 356 | }; | 146 | ApplnSettings m_appln_settings{}; |
| 357 | 147 | std::jthread m_save_thread; | |
| 358 | std::vector<AccountNotificationSettings> account_notifications{}; | 148 | std::mutex m_save_needed_mutex; |
| 359 | 149 | bool m_save_needed{false}; | |
| 360 | TvSettings tv_settings{ | ||
| 361 | .flags = {0xc}, | ||
| 362 | .tv_resolution = TvResolution::Auto, | ||
| 363 | .hdmi_content_type = HdmiContentType::Game, | ||
| 364 | .rgb_range = RgbRange::Auto, | ||
| 365 | .cmu_mode = CmuMode::None, | ||
| 366 | .tv_underscan = {}, | ||
| 367 | .tv_gama = 1.0f, | ||
| 368 | .constrast_ratio = 0.5f, | ||
| 369 | }; | ||
| 370 | |||
| 371 | InitialLaunchSettings launch_settings{ | ||
| 372 | .flags = {0x10001}, | ||
| 373 | .timestamp = {}, | ||
| 374 | }; | ||
| 375 | |||
| 376 | SleepSettings sleep_settings{ | ||
| 377 | .flags = {0x3}, | ||
| 378 | .handheld_sleep_plan = HandheldSleepPlan::Sleep10Min, | ||
| 379 | .console_sleep_plan = ConsoleSleepPlan::Sleep1Hour, | ||
| 380 | }; | ||
| 381 | |||
| 382 | u32 applet_launch_flag{}; | ||
| 383 | |||
| 384 | std::vector<EulaVersion> eula_versions{}; | ||
| 385 | |||
| 386 | RegionCode region_code; | ||
| 387 | |||
| 388 | LanguageCode language_code_setting; | ||
| 389 | }; | 150 | }; |
| 390 | 151 | ||
| 391 | } // namespace Service::Set | 152 | } // namespace Service::Set |
diff --git a/src/core/hle/service/set/system_settings.cpp b/src/core/hle/service/set/system_settings.cpp new file mode 100644 index 000000000..2723417ad --- /dev/null +++ b/src/core/hle/service/set/system_settings.cpp | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "core/hle/service/set/system_settings.h" | ||
| 5 | |||
| 6 | namespace Service::Set { | ||
| 7 | |||
| 8 | SystemSettings DefaultSystemSettings() { | ||
| 9 | SystemSettings settings{}; | ||
| 10 | |||
| 11 | settings.version = 0x140000; | ||
| 12 | settings.flags = 7; | ||
| 13 | |||
| 14 | settings.color_set_id = ColorSet::BasicWhite; | ||
| 15 | |||
| 16 | settings.notification_settings = { | ||
| 17 | .flags{0x300}, | ||
| 18 | .volume = NotificationVolume::High, | ||
| 19 | .start_time = {.hour = 9, .minute = 0}, | ||
| 20 | .stop_time = {.hour = 21, .minute = 0}, | ||
| 21 | }; | ||
| 22 | |||
| 23 | settings.tv_settings = { | ||
| 24 | .flags = {0xC}, | ||
| 25 | .tv_resolution = TvResolution::Auto, | ||
| 26 | .hdmi_content_type = HdmiContentType::Game, | ||
| 27 | .rgb_range = RgbRange::Auto, | ||
| 28 | .cmu_mode = CmuMode::None, | ||
| 29 | .tv_underscan = {}, | ||
| 30 | .tv_gama = 1.0f, | ||
| 31 | .constrast_ratio = 0.5f, | ||
| 32 | }; | ||
| 33 | |||
| 34 | settings.initial_launch_settings_packed = { | ||
| 35 | .flags = {0x10001}, | ||
| 36 | .timestamp = {}, | ||
| 37 | }; | ||
| 38 | |||
| 39 | settings.sleep_settings = { | ||
| 40 | .flags = {0x3}, | ||
| 41 | .handheld_sleep_plan = HandheldSleepPlan::Sleep10Min, | ||
| 42 | .console_sleep_plan = ConsoleSleepPlan::Sleep1Hour, | ||
| 43 | }; | ||
| 44 | |||
| 45 | settings.device_time_zone_location_name = {"UTC"}; | ||
| 46 | settings.user_system_clock_automatic_correction_enabled = false; | ||
| 47 | |||
| 48 | return settings; | ||
| 49 | } | ||
| 50 | |||
| 51 | } // namespace Service::Set | ||
diff --git a/src/core/hle/service/set/system_settings.h b/src/core/hle/service/set/system_settings.h new file mode 100644 index 000000000..ded2906ad --- /dev/null +++ b/src/core/hle/service/set/system_settings.h | |||
| @@ -0,0 +1,699 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <array> | ||
| 7 | |||
| 8 | #include "common/bit_field.h" | ||
| 9 | #include "common/common_funcs.h" | ||
| 10 | #include "common/common_types.h" | ||
| 11 | #include "core/hle/service/set/private_settings.h" | ||
| 12 | #include "core/hle/service/time/clock_types.h" | ||
| 13 | |||
| 14 | namespace Service::Set { | ||
| 15 | |||
| 16 | /// This is "nn::settings::LanguageCode", which is a NUL-terminated string stored in a u64. | ||
| 17 | enum class LanguageCode : u64 { | ||
| 18 | JA = 0x000000000000616A, | ||
| 19 | EN_US = 0x00000053552D6E65, | ||
| 20 | FR = 0x0000000000007266, | ||
| 21 | DE = 0x0000000000006564, | ||
| 22 | IT = 0x0000000000007469, | ||
| 23 | ES = 0x0000000000007365, | ||
| 24 | ZH_CN = 0x0000004E432D687A, | ||
| 25 | KO = 0x0000000000006F6B, | ||
| 26 | NL = 0x0000000000006C6E, | ||
| 27 | PT = 0x0000000000007470, | ||
| 28 | RU = 0x0000000000007572, | ||
| 29 | ZH_TW = 0x00000057542D687A, | ||
| 30 | EN_GB = 0x00000042472D6E65, | ||
| 31 | FR_CA = 0x00000041432D7266, | ||
| 32 | ES_419 = 0x00003931342D7365, | ||
| 33 | ZH_HANS = 0x00736E61482D687A, | ||
| 34 | ZH_HANT = 0x00746E61482D687A, | ||
| 35 | PT_BR = 0x00000052422D7470, | ||
| 36 | }; | ||
| 37 | |||
| 38 | /// This is nn::settings::system::ErrorReportSharePermission | ||
| 39 | enum class ErrorReportSharePermission : u32 { | ||
| 40 | NotConfirmed, | ||
| 41 | Granted, | ||
| 42 | Denied, | ||
| 43 | }; | ||
| 44 | |||
| 45 | /// This is nn::settings::system::ChineseTraditionalInputMethod | ||
| 46 | enum class ChineseTraditionalInputMethod : u32 { | ||
| 47 | Unknown0 = 0, | ||
| 48 | Unknown1 = 1, | ||
| 49 | Unknown2 = 2, | ||
| 50 | }; | ||
| 51 | |||
| 52 | /// This is nn::settings::system::HomeMenuScheme | ||
| 53 | struct HomeMenuScheme { | ||
| 54 | u32 main; | ||
| 55 | u32 back; | ||
| 56 | u32 sub; | ||
| 57 | u32 bezel; | ||
| 58 | u32 extra; | ||
| 59 | }; | ||
| 60 | static_assert(sizeof(HomeMenuScheme) == 0x14, "HomeMenuScheme is incorrect size"); | ||
| 61 | |||
| 62 | /// Indicates the current theme set by the system settings | ||
| 63 | enum class ColorSet : u32 { | ||
| 64 | BasicWhite = 0, | ||
| 65 | BasicBlack = 1, | ||
| 66 | }; | ||
| 67 | |||
| 68 | /// Indicates the current console is a retail or kiosk unit | ||
| 69 | enum class QuestFlag : u8 { | ||
| 70 | Retail = 0, | ||
| 71 | Kiosk = 1, | ||
| 72 | }; | ||
| 73 | |||
| 74 | /// This is nn::settings::system::RegionCode | ||
| 75 | enum class RegionCode : u32 { | ||
| 76 | Japan, | ||
| 77 | Usa, | ||
| 78 | Europe, | ||
| 79 | Australia, | ||
| 80 | HongKongTaiwanKorea, | ||
| 81 | China, | ||
| 82 | }; | ||
| 83 | |||
| 84 | /// This is nn::settings::system::AccountSettings | ||
| 85 | struct AccountSettings { | ||
| 86 | u32 flags; | ||
| 87 | }; | ||
| 88 | static_assert(sizeof(AccountSettings) == 4, "AccountSettings is an invalid size"); | ||
| 89 | |||
| 90 | /// This is nn::settings::system::NotificationVolume | ||
| 91 | enum class NotificationVolume : u32 { | ||
| 92 | Mute, | ||
| 93 | Low, | ||
| 94 | High, | ||
| 95 | }; | ||
| 96 | |||
| 97 | /// This is nn::settings::system::NotificationFlag | ||
| 98 | struct NotificationFlag { | ||
| 99 | union { | ||
| 100 | u32 raw{}; | ||
| 101 | |||
| 102 | BitField<0, 1, u32> RingtoneFlag; | ||
| 103 | BitField<1, 1, u32> DownloadCompletionFlag; | ||
| 104 | BitField<8, 1, u32> EnablesNews; | ||
| 105 | BitField<9, 1, u32> IncomingLampFlag; | ||
| 106 | }; | ||
| 107 | }; | ||
| 108 | static_assert(sizeof(NotificationFlag) == 4, "NotificationFlag is an invalid size"); | ||
| 109 | |||
| 110 | /// This is nn::settings::system::NotificationTime | ||
| 111 | struct NotificationTime { | ||
| 112 | u32 hour; | ||
| 113 | u32 minute; | ||
| 114 | }; | ||
| 115 | static_assert(sizeof(NotificationTime) == 0x8, "NotificationTime is an invalid size"); | ||
| 116 | |||
| 117 | /// This is nn::settings::system::NotificationSettings | ||
| 118 | struct NotificationSettings { | ||
| 119 | NotificationFlag flags; | ||
| 120 | NotificationVolume volume; | ||
| 121 | NotificationTime start_time; | ||
| 122 | NotificationTime stop_time; | ||
| 123 | }; | ||
| 124 | static_assert(sizeof(NotificationSettings) == 0x18, "NotificationSettings is an invalid size"); | ||
| 125 | |||
| 126 | /// This is nn::settings::system::AccountNotificationFlag | ||
| 127 | struct AccountNotificationFlag { | ||
| 128 | union { | ||
| 129 | u32 raw{}; | ||
| 130 | |||
| 131 | BitField<0, 1, u32> FriendOnlineFlag; | ||
| 132 | BitField<1, 1, u32> FriendRequestFlag; | ||
| 133 | BitField<8, 1, u32> CoralInvitationFlag; | ||
| 134 | }; | ||
| 135 | }; | ||
| 136 | static_assert(sizeof(AccountNotificationFlag) == 4, "AccountNotificationFlag is an invalid size"); | ||
| 137 | |||
| 138 | /// This is nn::settings::system::FriendPresenceOverlayPermission | ||
| 139 | enum class FriendPresenceOverlayPermission : u8 { | ||
| 140 | NotConfirmed, | ||
| 141 | NoDisplay, | ||
| 142 | FavoriteFriends, | ||
| 143 | Friends, | ||
| 144 | }; | ||
| 145 | |||
| 146 | /// This is nn::settings::system::AccountNotificationSettings | ||
| 147 | struct AccountNotificationSettings { | ||
| 148 | Common::UUID uid; | ||
| 149 | AccountNotificationFlag flags; | ||
| 150 | FriendPresenceOverlayPermission friend_presence_permission; | ||
| 151 | FriendPresenceOverlayPermission friend_invitation_permission; | ||
| 152 | INSERT_PADDING_BYTES(0x2); | ||
| 153 | }; | ||
| 154 | static_assert(sizeof(AccountNotificationSettings) == 0x18, | ||
| 155 | "AccountNotificationSettings is an invalid size"); | ||
| 156 | |||
| 157 | /// This is nn::settings::system::TvFlag | ||
| 158 | struct TvFlag { | ||
| 159 | union { | ||
| 160 | u32 raw{}; | ||
| 161 | |||
| 162 | BitField<0, 1, u32> Allows4k; | ||
| 163 | BitField<1, 1, u32> Allows3d; | ||
| 164 | BitField<2, 1, u32> AllowsCec; | ||
| 165 | BitField<3, 1, u32> PreventsScreenBurnIn; | ||
| 166 | }; | ||
| 167 | }; | ||
| 168 | static_assert(sizeof(TvFlag) == 4, "TvFlag is an invalid size"); | ||
| 169 | |||
| 170 | /// This is nn::settings::system::TvResolution | ||
| 171 | enum class TvResolution : u32 { | ||
| 172 | Auto, | ||
| 173 | Resolution1080p, | ||
| 174 | Resolution720p, | ||
| 175 | Resolution480p, | ||
| 176 | }; | ||
| 177 | |||
| 178 | /// This is nn::settings::system::HdmiContentType | ||
| 179 | enum class HdmiContentType : u32 { | ||
| 180 | None, | ||
| 181 | Graphics, | ||
| 182 | Cinema, | ||
| 183 | Photo, | ||
| 184 | Game, | ||
| 185 | }; | ||
| 186 | |||
| 187 | /// This is nn::settings::system::RgbRange | ||
| 188 | enum class RgbRange : u32 { | ||
| 189 | Auto, | ||
| 190 | Full, | ||
| 191 | Limited, | ||
| 192 | }; | ||
| 193 | |||
| 194 | /// This is nn::settings::system::CmuMode | ||
| 195 | enum class CmuMode : u32 { | ||
| 196 | None, | ||
| 197 | ColorInvert, | ||
| 198 | HighContrast, | ||
| 199 | GrayScale, | ||
| 200 | }; | ||
| 201 | |||
| 202 | /// This is nn::settings::system::TvSettings | ||
| 203 | struct TvSettings { | ||
| 204 | TvFlag flags; | ||
| 205 | TvResolution tv_resolution; | ||
| 206 | HdmiContentType hdmi_content_type; | ||
| 207 | RgbRange rgb_range; | ||
| 208 | CmuMode cmu_mode; | ||
| 209 | u32 tv_underscan; | ||
| 210 | f32 tv_gama; | ||
| 211 | f32 constrast_ratio; | ||
| 212 | }; | ||
| 213 | static_assert(sizeof(TvSettings) == 0x20, "TvSettings is an invalid size"); | ||
| 214 | |||
| 215 | /// This is nn::settings::system::PrimaryAlbumStorage | ||
| 216 | enum class PrimaryAlbumStorage : u32 { | ||
| 217 | Nand, | ||
| 218 | SdCard, | ||
| 219 | }; | ||
| 220 | |||
| 221 | /// This is nn::settings::system::HandheldSleepPlan | ||
| 222 | enum class HandheldSleepPlan : u32 { | ||
| 223 | Sleep1Min, | ||
| 224 | Sleep3Min, | ||
| 225 | Sleep5Min, | ||
| 226 | Sleep10Min, | ||
| 227 | Sleep30Min, | ||
| 228 | Never, | ||
| 229 | }; | ||
| 230 | |||
| 231 | /// This is nn::settings::system::ConsoleSleepPlan | ||
| 232 | enum class ConsoleSleepPlan : u32 { | ||
| 233 | Sleep1Hour, | ||
| 234 | Sleep2Hour, | ||
| 235 | Sleep3Hour, | ||
| 236 | Sleep6Hour, | ||
| 237 | Sleep12Hour, | ||
| 238 | Never, | ||
| 239 | }; | ||
| 240 | |||
| 241 | /// This is nn::settings::system::SleepFlag | ||
| 242 | struct SleepFlag { | ||
| 243 | union { | ||
| 244 | u32 raw{}; | ||
| 245 | |||
| 246 | BitField<0, 1, u32> SleepsWhilePlayingMedia; | ||
| 247 | BitField<1, 1, u32> WakesAtPowerStateChange; | ||
| 248 | }; | ||
| 249 | }; | ||
| 250 | static_assert(sizeof(SleepFlag) == 4, "TvFlag is an invalid size"); | ||
| 251 | |||
| 252 | /// This is nn::settings::system::SleepSettings | ||
| 253 | struct SleepSettings { | ||
| 254 | SleepFlag flags; | ||
| 255 | HandheldSleepPlan handheld_sleep_plan; | ||
| 256 | ConsoleSleepPlan console_sleep_plan; | ||
| 257 | }; | ||
| 258 | static_assert(sizeof(SleepSettings) == 0xc, "SleepSettings is incorrect size"); | ||
| 259 | |||
| 260 | /// This is nn::settings::system::EulaVersionClockType | ||
| 261 | enum class EulaVersionClockType : u32 { | ||
| 262 | NetworkSystemClock, | ||
| 263 | SteadyClock, | ||
| 264 | }; | ||
| 265 | |||
| 266 | /// This is nn::settings::system::EulaVersion | ||
| 267 | struct EulaVersion { | ||
| 268 | u32 version; | ||
| 269 | RegionCode region_code; | ||
| 270 | EulaVersionClockType clock_type; | ||
| 271 | INSERT_PADDING_BYTES(0x4); | ||
| 272 | s64 posix_time; | ||
| 273 | Time::Clock::SteadyClockTimePoint timestamp; | ||
| 274 | }; | ||
| 275 | static_assert(sizeof(EulaVersion) == 0x30, "EulaVersion is incorrect size"); | ||
| 276 | |||
| 277 | struct SystemSettings { | ||
| 278 | // 0/unwritten (1.0.0), 0x20000 (2.0.0), 0x30000 (3.0.0-3.0.1), 0x40001 (4.0.0-4.1.0), 0x50000 | ||
| 279 | // (5.0.0-5.1.0), 0x60000 (6.0.0-6.2.0), 0x70000 (7.0.0), 0x80000 (8.0.0-8.1.1), 0x90000 | ||
| 280 | // (9.0.0-10.0.4), 0x100100 (10.1.0+), 0x120000 (12.0.0-12.1.0), 0x130000 (13.0.0-13.2.1), | ||
| 281 | // 0x140000 (14.0.0+) | ||
| 282 | u32 version; | ||
| 283 | // 0/unwritten (1.0.0), 1 (6.0.0-8.1.0), 2 (8.1.1), 7 (9.0.0+). | ||
| 284 | // if (flags & 2), defaults are written for AnalogStickUserCalibration | ||
| 285 | u32 flags; | ||
| 286 | |||
| 287 | std::array<u8, 0x8> reserved_00008; | ||
| 288 | |||
| 289 | // nn::settings::LanguageCode | ||
| 290 | LanguageCode language_code; | ||
| 291 | |||
| 292 | std::array<u8, 0x38> reserved_00018; | ||
| 293 | |||
| 294 | // nn::settings::system::NetworkSettings | ||
| 295 | u32 network_setting_count; | ||
| 296 | bool wireless_lan_enable_flag; | ||
| 297 | std::array<u8, 0x3> pad_00055; | ||
| 298 | |||
| 299 | std::array<u8, 0x8> reserved_00058; | ||
| 300 | |||
| 301 | // nn::settings::system::NetworkSettings | ||
| 302 | std::array<std::array<u8, 0x400>, 32> network_settings_1B0; | ||
| 303 | |||
| 304 | // nn::settings::system::BluetoothDevicesSettings | ||
| 305 | std::array<u8, 0x4> bluetooth_device_settings_count; | ||
| 306 | bool bluetooth_enable_flag; | ||
| 307 | std::array<u8, 0x3> pad_08065; | ||
| 308 | bool bluetooth_afh_enable_flag; | ||
| 309 | std::array<u8, 0x3> pad_08069; | ||
| 310 | bool bluetooth_boost_enable_flag; | ||
| 311 | std::array<u8, 0x3> pad_0806D; | ||
| 312 | std::array<std::array<u8, 0x200>, 10> bluetooth_device_settings_first_10; | ||
| 313 | |||
| 314 | s32 ldn_channel; | ||
| 315 | |||
| 316 | std::array<u8, 0x3C> reserved_09474; | ||
| 317 | |||
| 318 | // nn::util::Uuid MiiAuthorId | ||
| 319 | std::array<u8, 0x10> mii_author_id; | ||
| 320 | |||
| 321 | std::array<u8, 0x30> reserved_094C0; | ||
| 322 | |||
| 323 | // nn::settings::system::NxControllerSettings | ||
| 324 | u32 nx_controller_settings_count; | ||
| 325 | |||
| 326 | std::array<u8, 0xC> reserved_094F4; | ||
| 327 | |||
| 328 | // nn::settings::system::NxControllerSettings, | ||
| 329 | // nn::settings::system::NxControllerLegacySettings on 13.0.0+ | ||
| 330 | std::array<std::array<u8, 0x40>, 10> nx_controller_legacy_settings; | ||
| 331 | |||
| 332 | std::array<u8, 0x170> reserved_09780; | ||
| 333 | |||
| 334 | bool external_rtc_reset_flag; | ||
| 335 | std::array<u8, 0x3> pad_098F1; | ||
| 336 | |||
| 337 | std::array<u8, 0x3C> reserved_098F4; | ||
| 338 | |||
| 339 | s32 push_notification_activity_mode_on_sleep; | ||
| 340 | |||
| 341 | std::array<u8, 0x3C> reserved_09934; | ||
| 342 | |||
| 343 | // nn::settings::system::ErrorReportSharePermission | ||
| 344 | ErrorReportSharePermission error_report_share_permssion; | ||
| 345 | |||
| 346 | std::array<u8, 0x3C> reserved_09974; | ||
| 347 | |||
| 348 | // nn::settings::KeyboardLayout | ||
| 349 | std::array<u8, 0x4> keyboard_layout; | ||
| 350 | |||
| 351 | std::array<u8, 0x3C> reserved_099B4; | ||
| 352 | |||
| 353 | bool web_inspector_flag; | ||
| 354 | std::array<u8, 0x3> pad_099F1; | ||
| 355 | |||
| 356 | // nn::settings::system::AllowedSslHost | ||
| 357 | u32 allowed_ssl_host_count; | ||
| 358 | |||
| 359 | bool memory_usage_rate_flag; | ||
| 360 | std::array<u8, 0x3> pad_099F9; | ||
| 361 | |||
| 362 | std::array<u8, 0x34> reserved_099FC; | ||
| 363 | |||
| 364 | // nn::settings::system::HostFsMountPoint | ||
| 365 | std::array<u8, 0x100> host_fs_mount_point; | ||
| 366 | |||
| 367 | // nn::settings::system::AllowedSslHost | ||
| 368 | std::array<std::array<u8, 0x100>, 8> allowed_ssl_hosts; | ||
| 369 | |||
| 370 | std::array<u8, 0x6C0> reserved_0A330; | ||
| 371 | |||
| 372 | // nn::settings::system::BlePairingSettings | ||
| 373 | u32 ble_pairing_settings_count; | ||
| 374 | std::array<u8, 0xC> reserved_0A9F4; | ||
| 375 | std::array<std::array<u8, 0x80>, 10> ble_pairing_settings; | ||
| 376 | |||
| 377 | // nn::settings::system::AccountOnlineStorageSettings | ||
| 378 | u32 account_online_storage_settings_count; | ||
| 379 | std::array<u8, 0xC> reserved_0AF04; | ||
| 380 | std::array<std::array<u8, 0x40>, 8> account_online_storage_settings; | ||
| 381 | |||
| 382 | bool pctl_ready_flag; | ||
| 383 | std::array<u8, 0x3> pad_0B111; | ||
| 384 | |||
| 385 | std::array<u8, 0x3C> reserved_0B114; | ||
| 386 | |||
| 387 | // nn::settings::system::ThemeId | ||
| 388 | std::array<u8, 0x80> theme_id_type0; | ||
| 389 | std::array<u8, 0x80> theme_id_type1; | ||
| 390 | |||
| 391 | std::array<u8, 0x100> reserved_0B250; | ||
| 392 | |||
| 393 | // nn::settings::ChineseTraditionalInputMethod | ||
| 394 | ChineseTraditionalInputMethod chinese_traditional_input_method; | ||
| 395 | |||
| 396 | std::array<u8, 0x3C> reserved_0B354; | ||
| 397 | |||
| 398 | bool zoom_flag; | ||
| 399 | std::array<u8, 0x3> pad_0B391; | ||
| 400 | |||
| 401 | std::array<u8, 0x3C> reserved_0B394; | ||
| 402 | |||
| 403 | // nn::settings::system::ButtonConfigRegisteredSettings | ||
| 404 | u32 button_config_registered_settings_count; | ||
| 405 | std::array<u8, 0xC> reserved_0B3D4; | ||
| 406 | |||
| 407 | // nn::settings::system::ButtonConfigSettings | ||
| 408 | u32 button_config_settings_count; | ||
| 409 | std::array<u8, 0x4> reserved_0B3E4; | ||
| 410 | std::array<std::array<u8, 0x5A8>, 5> button_config_settings; | ||
| 411 | std::array<u8, 0x13B0> reserved_0D030; | ||
| 412 | u32 button_config_settings_embedded_count; | ||
| 413 | std::array<u8, 0x4> reserved_0E3E4; | ||
| 414 | std::array<std::array<u8, 0x5A8>, 5> button_config_settings_embedded; | ||
| 415 | std::array<u8, 0x13B0> reserved_10030; | ||
| 416 | u32 button_config_settings_left_count; | ||
| 417 | std::array<u8, 0x4> reserved_113E4; | ||
| 418 | std::array<std::array<u8, 0x5A8>, 5> button_config_settings_left; | ||
| 419 | std::array<u8, 0x13B0> reserved_13030; | ||
| 420 | u32 button_config_settings_right_count; | ||
| 421 | std::array<u8, 0x4> reserved_143E4; | ||
| 422 | std::array<std::array<u8, 0x5A8>, 5> button_config_settings_right; | ||
| 423 | std::array<u8, 0x73B0> reserved_16030; | ||
| 424 | // nn::settings::system::ButtonConfigRegisteredSettings | ||
| 425 | std::array<u8, 0x5C8> button_config_registered_settings_embedded; | ||
| 426 | std::array<std::array<u8, 0x5C8>, 10> button_config_registered_settings; | ||
| 427 | |||
| 428 | std::array<u8, 0x7FF8> reserved_21378; | ||
| 429 | |||
| 430 | // nn::settings::system::ConsoleSixAxisSensorAccelerationBias | ||
| 431 | std::array<u8, 0xC> console_six_axis_sensor_acceleration_bias; | ||
| 432 | // nn::settings::system::ConsoleSixAxisSensorAngularVelocityBias | ||
| 433 | std::array<u8, 0xC> console_six_axis_sensor_angular_velocity_bias; | ||
| 434 | // nn::settings::system::ConsoleSixAxisSensorAccelerationGain | ||
| 435 | std::array<u8, 0x24> console_six_axis_sensor_acceleration_gain; | ||
| 436 | // nn::settings::system::ConsoleSixAxisSensorAngularVelocityGain | ||
| 437 | std::array<u8, 0x24> console_six_axis_sensor_angular_velocity_gain; | ||
| 438 | // nn::settings::system::ConsoleSixAxisSensorAngularVelocityTimeBias | ||
| 439 | std::array<u8, 0xC> console_six_axis_sensor_angular_velocity_time_bias; | ||
| 440 | // nn::settings::system::ConsoleSixAxisSensorAngularAcceleration | ||
| 441 | std::array<u8, 0x24> console_six_axis_sensor_angular_velocity_acceleration; | ||
| 442 | |||
| 443 | std::array<u8, 0x70> reserved_29400; | ||
| 444 | |||
| 445 | bool lock_screen_flag; | ||
| 446 | std::array<u8, 0x3> pad_29471; | ||
| 447 | |||
| 448 | std::array<u8, 0x4> reserved_249274; | ||
| 449 | |||
| 450 | ColorSet color_set_id; | ||
| 451 | |||
| 452 | QuestFlag quest_flag; | ||
| 453 | |||
| 454 | // nn::settings::system::RegionCode | ||
| 455 | RegionCode region_code; | ||
| 456 | |||
| 457 | // Different to nn::settings::system::InitialLaunchSettings? | ||
| 458 | InitialLaunchSettingsPacked initial_launch_settings_packed; | ||
| 459 | |||
| 460 | bool battery_percentage_flag; | ||
| 461 | std::array<u8, 0x3> pad_294A1; | ||
| 462 | |||
| 463 | // BitFlagSet<32, nn::settings::system::AppletLaunchFlag> | ||
| 464 | u32 applet_launch_flag; | ||
| 465 | |||
| 466 | // nn::settings::system::ThemeSettings | ||
| 467 | std::array<u8, 0x8> theme_settings; | ||
| 468 | // nn::fssystem::ArchiveMacKey | ||
| 469 | std::array<u8, 0x10> theme_key; | ||
| 470 | |||
| 471 | bool field_testing_flag; | ||
| 472 | std::array<u8, 0x3> pad_294C1; | ||
| 473 | |||
| 474 | s32 panel_crc_mode; | ||
| 475 | |||
| 476 | std::array<u8, 0x28> reserved_294C8; | ||
| 477 | |||
| 478 | // nn::settings::system::BacklightSettings | ||
| 479 | std::array<u8, 0x2C> backlight_settings_mixed_up; | ||
| 480 | |||
| 481 | std::array<u8, 0x64> reserved_2951C; | ||
| 482 | |||
| 483 | // nn::time::SystemClockContext | ||
| 484 | Service::Time::Clock::SystemClockContext user_system_clock_context; | ||
| 485 | Service::Time::Clock::SystemClockContext network_system_clock_context; | ||
| 486 | bool user_system_clock_automatic_correction_enabled; | ||
| 487 | std::array<u8, 0x3> pad_295C1; | ||
| 488 | std::array<u8, 0x4> reserved_295C4; | ||
| 489 | // nn::time::SteadyClockTimePoint | ||
| 490 | Service::Time::Clock::SteadyClockTimePoint | ||
| 491 | user_system_clock_automatic_correction_updated_time_point; | ||
| 492 | |||
| 493 | std::array<u8, 0x10> reserved_295E0; | ||
| 494 | |||
| 495 | // nn::settings::system::AccountSettings | ||
| 496 | AccountSettings account_settings; | ||
| 497 | |||
| 498 | std::array<u8, 0xFC> reserved_295F4; | ||
| 499 | |||
| 500 | // nn::settings::system::AudioVolume | ||
| 501 | std::array<u8, 0x8> audio_volume_type0; | ||
| 502 | std::array<u8, 0x8> audio_volume_type1; | ||
| 503 | // nn::settings::system::AudioOutputMode | ||
| 504 | s32 audio_output_mode_type0; | ||
| 505 | s32 audio_output_mode_type1; | ||
| 506 | s32 audio_output_mode_type2; | ||
| 507 | bool force_mute_on_headphone_removed; | ||
| 508 | std::array<u8, 0x3> pad_2970D; | ||
| 509 | s32 headphone_volume_warning_count; | ||
| 510 | bool heaphone_volume_update_flag; | ||
| 511 | std::array<u8, 0x3> pad_29715; | ||
| 512 | // nn::settings::system::AudioVolume | ||
| 513 | std::array<u8, 0x8> audio_volume_type2; | ||
| 514 | // nn::settings::system::AudioOutputMode | ||
| 515 | s32 audio_output_mode_type3; | ||
| 516 | s32 audio_output_mode_type4; | ||
| 517 | bool hearing_protection_safeguard_flag; | ||
| 518 | std::array<u8, 0x3> pad_29729; | ||
| 519 | std::array<u8, 0x4> reserved_2972C; | ||
| 520 | s64 hearing_protection_safeguard_remaining_time; | ||
| 521 | std::array<u8, 0x38> reserved_29738; | ||
| 522 | |||
| 523 | bool console_information_upload_flag; | ||
| 524 | std::array<u8, 0x3> pad_29771; | ||
| 525 | |||
| 526 | std::array<u8, 0x3C> reserved_29774; | ||
| 527 | |||
| 528 | bool automatic_application_download_flag; | ||
| 529 | std::array<u8, 0x3> pad_297B1; | ||
| 530 | |||
| 531 | std::array<u8, 0x4> reserved_297B4; | ||
| 532 | |||
| 533 | // nn::settings::system::NotificationSettings | ||
| 534 | NotificationSettings notification_settings; | ||
| 535 | |||
| 536 | std::array<u8, 0x60> reserved_297D0; | ||
| 537 | |||
| 538 | // nn::settings::system::AccountNotificationSettings | ||
| 539 | u32 account_notification_settings_count; | ||
| 540 | std::array<u8, 0xC> reserved_29834; | ||
| 541 | std::array<AccountNotificationSettings, 8> account_notification_settings; | ||
| 542 | |||
| 543 | std::array<u8, 0x140> reserved_29900; | ||
| 544 | |||
| 545 | f32 vibration_master_volume; | ||
| 546 | |||
| 547 | bool usb_full_key_enable_flag; | ||
| 548 | std::array<u8, 0x3> pad_29A45; | ||
| 549 | |||
| 550 | // nn::settings::system::AnalogStickUserCalibration | ||
| 551 | std::array<u8, 0x10> analog_stick_user_calibration_left; | ||
| 552 | std::array<u8, 0x10> analog_stick_user_calibration_right; | ||
| 553 | |||
| 554 | // nn::settings::system::TouchScreenMode | ||
| 555 | s32 touch_screen_mode; | ||
| 556 | |||
| 557 | std::array<u8, 0x14> reserved_29A6C; | ||
| 558 | |||
| 559 | // nn::settings::system::TvSettings | ||
| 560 | TvSettings tv_settings; | ||
| 561 | |||
| 562 | // nn::settings::system::Edid | ||
| 563 | std::array<u8, 0x100> edid; | ||
| 564 | |||
| 565 | std::array<u8, 0x2E0> reserved_29BA0; | ||
| 566 | |||
| 567 | // nn::settings::system::DataDeletionSettings | ||
| 568 | std::array<u8, 0x8> data_deletion_settings; | ||
| 569 | |||
| 570 | std::array<u8, 0x38> reserved_29E88; | ||
| 571 | |||
| 572 | // nn::ncm::ProgramId | ||
| 573 | std::array<u8, 0x8> initial_system_applet_program_id; | ||
| 574 | std::array<u8, 0x8> overlay_disp_program_id; | ||
| 575 | |||
| 576 | std::array<u8, 0x4> reserved_29ED0; | ||
| 577 | |||
| 578 | bool requires_run_repair_time_reviser; | ||
| 579 | |||
| 580 | std::array<u8, 0x6B> reserved_29ED5; | ||
| 581 | |||
| 582 | // nn::time::LocationName | ||
| 583 | Service::Time::TimeZone::LocationName device_time_zone_location_name; | ||
| 584 | std::array<u8, 0x4> reserved_29F64; | ||
| 585 | // nn::time::SteadyClockTimePoint | ||
| 586 | Service::Time::Clock::SteadyClockTimePoint device_time_zone_location_updated_time; | ||
| 587 | |||
| 588 | std::array<u8, 0xC0> reserved_29F80; | ||
| 589 | |||
| 590 | // nn::settings::system::PrimaryAlbumStorage | ||
| 591 | PrimaryAlbumStorage primary_album_storage; | ||
| 592 | |||
| 593 | std::array<u8, 0x3C> reserved_2A044; | ||
| 594 | |||
| 595 | bool usb_30_enable_flag; | ||
| 596 | std::array<u8, 0x3> pad_2A081; | ||
| 597 | bool usb_30_host_enable_flag; | ||
| 598 | std::array<u8, 0x3> pad_2A085; | ||
| 599 | bool usb_30_device_enable_flag; | ||
| 600 | std::array<u8, 0x3> pad_2A089; | ||
| 601 | |||
| 602 | std::array<u8, 0x34> reserved_2A08C; | ||
| 603 | |||
| 604 | bool nfc_enable_flag; | ||
| 605 | std::array<u8, 0x3> pad_2A0C1; | ||
| 606 | |||
| 607 | std::array<u8, 0x3C> reserved_2A0C4; | ||
| 608 | |||
| 609 | // nn::settings::system::SleepSettings | ||
| 610 | SleepSettings sleep_settings; | ||
| 611 | |||
| 612 | std::array<u8, 0x34> reserved_2A10C; | ||
| 613 | |||
| 614 | // nn::settings::system::EulaVersion | ||
| 615 | u32 eula_version_count; | ||
| 616 | std::array<u8, 0xC> reserved_2A144; | ||
| 617 | std::array<EulaVersion, 32> eula_versions; | ||
| 618 | |||
| 619 | std::array<u8, 0x200> reserved_2A750; | ||
| 620 | |||
| 621 | // nn::settings::system::DeviceNickName | ||
| 622 | std::array<u8, 0x80> device_nick_name; | ||
| 623 | |||
| 624 | std::array<u8, 0x80> reserved_2A9D0; | ||
| 625 | |||
| 626 | bool auto_update_enable_flag; | ||
| 627 | std::array<u8, 0x3> pad_2AA51; | ||
| 628 | |||
| 629 | std::array<u8, 0x4C> reserved_2AA54; | ||
| 630 | |||
| 631 | // nn::settings::system::BluetoothDevicesSettings | ||
| 632 | std::array<std::array<u8, 0x200>, 14> bluetooth_device_settings_last_14; | ||
| 633 | |||
| 634 | std::array<u8, 0x2000> reserved_2C6A0; | ||
| 635 | |||
| 636 | // nn::settings::system::NxControllerSettings | ||
| 637 | std::array<std::array<u8, 0x800>, 10> nx_controller_settings_data_from_offset_30; | ||
| 638 | }; | ||
| 639 | |||
| 640 | static_assert(offsetof(SystemSettings, language_code) == 0x10); | ||
| 641 | static_assert(offsetof(SystemSettings, network_setting_count) == 0x50); | ||
| 642 | static_assert(offsetof(SystemSettings, network_settings_1B0) == 0x60); | ||
| 643 | static_assert(offsetof(SystemSettings, bluetooth_device_settings_count) == 0x8060); | ||
| 644 | static_assert(offsetof(SystemSettings, bluetooth_enable_flag) == 0x8064); | ||
| 645 | static_assert(offsetof(SystemSettings, bluetooth_device_settings_first_10) == 0x8070); | ||
| 646 | static_assert(offsetof(SystemSettings, ldn_channel) == 0x9470); | ||
| 647 | static_assert(offsetof(SystemSettings, mii_author_id) == 0x94B0); | ||
| 648 | static_assert(offsetof(SystemSettings, nx_controller_settings_count) == 0x94F0); | ||
| 649 | static_assert(offsetof(SystemSettings, nx_controller_legacy_settings) == 0x9500); | ||
| 650 | static_assert(offsetof(SystemSettings, external_rtc_reset_flag) == 0x98F0); | ||
| 651 | static_assert(offsetof(SystemSettings, push_notification_activity_mode_on_sleep) == 0x9930); | ||
| 652 | static_assert(offsetof(SystemSettings, allowed_ssl_host_count) == 0x99F4); | ||
| 653 | static_assert(offsetof(SystemSettings, host_fs_mount_point) == 0x9A30); | ||
| 654 | static_assert(offsetof(SystemSettings, allowed_ssl_hosts) == 0x9B30); | ||
| 655 | static_assert(offsetof(SystemSettings, ble_pairing_settings_count) == 0xA9F0); | ||
| 656 | static_assert(offsetof(SystemSettings, ble_pairing_settings) == 0xAA00); | ||
| 657 | static_assert(offsetof(SystemSettings, account_online_storage_settings_count) == 0xAF00); | ||
| 658 | static_assert(offsetof(SystemSettings, account_online_storage_settings) == 0xAF10); | ||
| 659 | static_assert(offsetof(SystemSettings, pctl_ready_flag) == 0xB110); | ||
| 660 | static_assert(offsetof(SystemSettings, theme_id_type0) == 0xB150); | ||
| 661 | static_assert(offsetof(SystemSettings, chinese_traditional_input_method) == 0xB350); | ||
| 662 | static_assert(offsetof(SystemSettings, button_config_registered_settings_count) == 0xB3D0); | ||
| 663 | static_assert(offsetof(SystemSettings, button_config_settings_count) == 0xB3E0); | ||
| 664 | static_assert(offsetof(SystemSettings, button_config_settings) == 0xB3E8); | ||
| 665 | static_assert(offsetof(SystemSettings, button_config_registered_settings_embedded) == 0x1D3E0); | ||
| 666 | static_assert(offsetof(SystemSettings, console_six_axis_sensor_acceleration_bias) == 0x29370); | ||
| 667 | static_assert(offsetof(SystemSettings, lock_screen_flag) == 0x29470); | ||
| 668 | static_assert(offsetof(SystemSettings, battery_percentage_flag) == 0x294A0); | ||
| 669 | static_assert(offsetof(SystemSettings, field_testing_flag) == 0x294C0); | ||
| 670 | static_assert(offsetof(SystemSettings, backlight_settings_mixed_up) == 0x294F0); | ||
| 671 | static_assert(offsetof(SystemSettings, user_system_clock_context) == 0x29580); | ||
| 672 | static_assert(offsetof(SystemSettings, network_system_clock_context) == 0x295A0); | ||
| 673 | static_assert(offsetof(SystemSettings, user_system_clock_automatic_correction_enabled) == 0x295C0); | ||
| 674 | static_assert(offsetof(SystemSettings, user_system_clock_automatic_correction_updated_time_point) == | ||
| 675 | 0x295C8); | ||
| 676 | static_assert(offsetof(SystemSettings, account_settings) == 0x295F0); | ||
| 677 | static_assert(offsetof(SystemSettings, audio_volume_type0) == 0x296F0); | ||
| 678 | static_assert(offsetof(SystemSettings, hearing_protection_safeguard_remaining_time) == 0x29730); | ||
| 679 | static_assert(offsetof(SystemSettings, automatic_application_download_flag) == 0x297B0); | ||
| 680 | static_assert(offsetof(SystemSettings, notification_settings) == 0x297B8); | ||
| 681 | static_assert(offsetof(SystemSettings, account_notification_settings) == 0x29840); | ||
| 682 | static_assert(offsetof(SystemSettings, vibration_master_volume) == 0x29A40); | ||
| 683 | static_assert(offsetof(SystemSettings, analog_stick_user_calibration_left) == 0x29A48); | ||
| 684 | static_assert(offsetof(SystemSettings, touch_screen_mode) == 0x29A68); | ||
| 685 | static_assert(offsetof(SystemSettings, edid) == 0x29AA0); | ||
| 686 | static_assert(offsetof(SystemSettings, data_deletion_settings) == 0x29E80); | ||
| 687 | static_assert(offsetof(SystemSettings, requires_run_repair_time_reviser) == 0x29ED4); | ||
| 688 | static_assert(offsetof(SystemSettings, device_time_zone_location_name) == 0x29F40); | ||
| 689 | static_assert(offsetof(SystemSettings, nfc_enable_flag) == 0x2A0C0); | ||
| 690 | static_assert(offsetof(SystemSettings, eula_version_count) == 0x2A140); | ||
| 691 | static_assert(offsetof(SystemSettings, device_nick_name) == 0x2A950); | ||
| 692 | static_assert(offsetof(SystemSettings, bluetooth_device_settings_last_14) == 0x2AAA0); | ||
| 693 | static_assert(offsetof(SystemSettings, nx_controller_settings_data_from_offset_30) == 0x2E6A0); | ||
| 694 | |||
| 695 | static_assert(sizeof(SystemSettings) == 0x336A0, "SystemSettings has the wrong size!"); | ||
| 696 | |||
| 697 | SystemSettings DefaultSystemSettings(); | ||
| 698 | |||
| 699 | } // namespace Service::Set | ||
diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index e0cde9a05..296ee6e89 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp | |||
| @@ -51,7 +51,7 @@ static Result ValidateServiceName(const std::string& name) { | |||
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | Result ServiceManager::RegisterService(std::string name, u32 max_sessions, | 53 | Result ServiceManager::RegisterService(std::string name, u32 max_sessions, |
| 54 | SessionRequestHandlerPtr handler) { | 54 | SessionRequestHandlerFactory handler) { |
| 55 | R_TRY(ValidateServiceName(name)); | 55 | R_TRY(ValidateServiceName(name)); |
| 56 | 56 | ||
| 57 | std::scoped_lock lk{lock}; | 57 | std::scoped_lock lk{lock}; |
| @@ -121,7 +121,7 @@ void SM::Initialize(HLERequestContext& ctx) { | |||
| 121 | rb.Push(ResultSuccess); | 121 | rb.Push(ResultSuccess); |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | void SM::GetService(HLERequestContext& ctx) { | 124 | void SM::GetServiceCmif(HLERequestContext& ctx) { |
| 125 | Kernel::KClientSession* client_session{}; | 125 | Kernel::KClientSession* client_session{}; |
| 126 | auto result = GetServiceImpl(&client_session, ctx); | 126 | auto result = GetServiceImpl(&client_session, ctx); |
| 127 | if (ctx.GetIsDeferred()) { | 127 | if (ctx.GetIsDeferred()) { |
| @@ -196,13 +196,28 @@ Result SM::GetServiceImpl(Kernel::KClientSession** out_client_session, HLEReques | |||
| 196 | return ResultSuccess; | 196 | return ResultSuccess; |
| 197 | } | 197 | } |
| 198 | 198 | ||
| 199 | void SM::RegisterService(HLERequestContext& ctx) { | 199 | void SM::RegisterServiceCmif(HLERequestContext& ctx) { |
| 200 | IPC::RequestParser rp{ctx}; | 200 | IPC::RequestParser rp{ctx}; |
| 201 | std::string name(PopServiceName(rp)); | 201 | std::string name(PopServiceName(rp)); |
| 202 | 202 | ||
| 203 | const auto is_light = static_cast<bool>(rp.PopRaw<u32>()); | 203 | const auto is_light = static_cast<bool>(rp.PopRaw<u32>()); |
| 204 | const auto max_session_count = rp.PopRaw<u32>(); | 204 | const auto max_session_count = rp.PopRaw<u32>(); |
| 205 | 205 | ||
| 206 | this->RegisterServiceImpl(ctx, name, max_session_count, is_light); | ||
| 207 | } | ||
| 208 | |||
| 209 | void SM::RegisterServiceTipc(HLERequestContext& ctx) { | ||
| 210 | IPC::RequestParser rp{ctx}; | ||
| 211 | std::string name(PopServiceName(rp)); | ||
| 212 | |||
| 213 | const auto max_session_count = rp.PopRaw<u32>(); | ||
| 214 | const auto is_light = static_cast<bool>(rp.PopRaw<u32>()); | ||
| 215 | |||
| 216 | this->RegisterServiceImpl(ctx, name, max_session_count, is_light); | ||
| 217 | } | ||
| 218 | |||
| 219 | void SM::RegisterServiceImpl(HLERequestContext& ctx, std::string name, u32 max_session_count, | ||
| 220 | bool is_light) { | ||
| 206 | LOG_DEBUG(Service_SM, "called with name={}, max_session_count={}, is_light={}", name, | 221 | LOG_DEBUG(Service_SM, "called with name={}, max_session_count={}, is_light={}", name, |
| 207 | max_session_count, is_light); | 222 | max_session_count, is_light); |
| 208 | 223 | ||
| @@ -238,15 +253,15 @@ SM::SM(ServiceManager& service_manager_, Core::System& system_) | |||
| 238 | service_manager{service_manager_}, kernel{system_.Kernel()} { | 253 | service_manager{service_manager_}, kernel{system_.Kernel()} { |
| 239 | RegisterHandlers({ | 254 | RegisterHandlers({ |
| 240 | {0, &SM::Initialize, "Initialize"}, | 255 | {0, &SM::Initialize, "Initialize"}, |
| 241 | {1, &SM::GetService, "GetService"}, | 256 | {1, &SM::GetServiceCmif, "GetService"}, |
| 242 | {2, &SM::RegisterService, "RegisterService"}, | 257 | {2, &SM::RegisterServiceCmif, "RegisterService"}, |
| 243 | {3, &SM::UnregisterService, "UnregisterService"}, | 258 | {3, &SM::UnregisterService, "UnregisterService"}, |
| 244 | {4, nullptr, "DetachClient"}, | 259 | {4, nullptr, "DetachClient"}, |
| 245 | }); | 260 | }); |
| 246 | RegisterHandlersTipc({ | 261 | RegisterHandlersTipc({ |
| 247 | {0, &SM::Initialize, "Initialize"}, | 262 | {0, &SM::Initialize, "Initialize"}, |
| 248 | {1, &SM::GetServiceTipc, "GetService"}, | 263 | {1, &SM::GetServiceTipc, "GetService"}, |
| 249 | {2, &SM::RegisterService, "RegisterService"}, | 264 | {2, &SM::RegisterServiceTipc, "RegisterService"}, |
| 250 | {3, &SM::UnregisterService, "UnregisterService"}, | 265 | {3, &SM::UnregisterService, "UnregisterService"}, |
| 251 | {4, nullptr, "DetachClient"}, | 266 | {4, nullptr, "DetachClient"}, |
| 252 | }); | 267 | }); |
| @@ -262,7 +277,9 @@ void LoopProcess(Core::System& system) { | |||
| 262 | server_manager->ManageDeferral(&deferral_event); | 277 | server_manager->ManageDeferral(&deferral_event); |
| 263 | service_manager.SetDeferralEvent(deferral_event); | 278 | service_manager.SetDeferralEvent(deferral_event); |
| 264 | 279 | ||
| 265 | server_manager->ManageNamedPort("sm:", std::make_shared<SM>(system.ServiceManager(), system)); | 280 | auto sm_service = std::make_shared<SM>(system.ServiceManager(), system); |
| 281 | server_manager->ManageNamedPort("sm:", [sm_service] { return sm_service; }); | ||
| 282 | |||
| 266 | ServerManager::RunServer(std::move(server_manager)); | 283 | ServerManager::RunServer(std::move(server_manager)); |
| 267 | } | 284 | } |
| 268 | 285 | ||
diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h index 14bfaf8c2..ff74f588a 100644 --- a/src/core/hle/service/sm/sm.h +++ b/src/core/hle/service/sm/sm.h | |||
| @@ -37,12 +37,15 @@ public: | |||
| 37 | 37 | ||
| 38 | private: | 38 | private: |
| 39 | void Initialize(HLERequestContext& ctx); | 39 | void Initialize(HLERequestContext& ctx); |
| 40 | void GetService(HLERequestContext& ctx); | 40 | void GetServiceCmif(HLERequestContext& ctx); |
| 41 | void GetServiceTipc(HLERequestContext& ctx); | 41 | void GetServiceTipc(HLERequestContext& ctx); |
| 42 | void RegisterService(HLERequestContext& ctx); | 42 | void RegisterServiceCmif(HLERequestContext& ctx); |
| 43 | void RegisterServiceTipc(HLERequestContext& ctx); | ||
| 43 | void UnregisterService(HLERequestContext& ctx); | 44 | void UnregisterService(HLERequestContext& ctx); |
| 44 | 45 | ||
| 45 | Result GetServiceImpl(Kernel::KClientSession** out_client_session, HLERequestContext& ctx); | 46 | Result GetServiceImpl(Kernel::KClientSession** out_client_session, HLERequestContext& ctx); |
| 47 | void RegisterServiceImpl(HLERequestContext& ctx, std::string name, u32 max_session_count, | ||
| 48 | bool is_light); | ||
| 46 | 49 | ||
| 47 | ServiceManager& service_manager; | 50 | ServiceManager& service_manager; |
| 48 | Kernel::KernelCore& kernel; | 51 | Kernel::KernelCore& kernel; |
| @@ -53,7 +56,8 @@ public: | |||
| 53 | explicit ServiceManager(Kernel::KernelCore& kernel_); | 56 | explicit ServiceManager(Kernel::KernelCore& kernel_); |
| 54 | ~ServiceManager(); | 57 | ~ServiceManager(); |
| 55 | 58 | ||
| 56 | Result RegisterService(std::string name, u32 max_sessions, SessionRequestHandlerPtr handler); | 59 | Result RegisterService(std::string name, u32 max_sessions, |
| 60 | SessionRequestHandlerFactory handler_factory); | ||
| 57 | Result UnregisterService(const std::string& name); | 61 | Result UnregisterService(const std::string& name); |
| 58 | Result GetServicePort(Kernel::KPort** out_port, const std::string& name); | 62 | Result GetServicePort(Kernel::KPort** out_port, const std::string& name); |
| 59 | 63 | ||
| @@ -64,7 +68,7 @@ public: | |||
| 64 | LOG_DEBUG(Service, "Can't find service: {}", service_name); | 68 | LOG_DEBUG(Service, "Can't find service: {}", service_name); |
| 65 | return nullptr; | 69 | return nullptr; |
| 66 | } | 70 | } |
| 67 | return std::static_pointer_cast<T>(service->second); | 71 | return std::static_pointer_cast<T>(service->second()); |
| 68 | } | 72 | } |
| 69 | 73 | ||
| 70 | void InvokeControlRequest(HLERequestContext& context); | 74 | void InvokeControlRequest(HLERequestContext& context); |
| @@ -79,7 +83,7 @@ private: | |||
| 79 | 83 | ||
| 80 | /// Map of registered services, retrieved using GetServicePort. | 84 | /// Map of registered services, retrieved using GetServicePort. |
| 81 | std::mutex lock; | 85 | std::mutex lock; |
| 82 | std::unordered_map<std::string, SessionRequestHandlerPtr> registered_services; | 86 | std::unordered_map<std::string, SessionRequestHandlerFactory> registered_services; |
| 83 | std::unordered_map<std::string, Kernel::KPort*> service_ports; | 87 | std::unordered_map<std::string, Kernel::KPort*> service_ports; |
| 84 | 88 | ||
| 85 | /// Kernel context | 89 | /// Kernel context |
diff --git a/src/core/hle/service/ssl/ssl.cpp b/src/core/hle/service/ssl/ssl.cpp index 6c8427b0d..0fbb43057 100644 --- a/src/core/hle/service/ssl/ssl.cpp +++ b/src/core/hle/service/ssl/ssl.cpp | |||
| @@ -240,7 +240,7 @@ private: | |||
| 240 | return ret; | 240 | return ret; |
| 241 | } | 241 | } |
| 242 | 242 | ||
| 243 | Result ReadImpl(std::vector<u8>* out_data, size_t size) { | 243 | Result ReadImpl(std::vector<u8>* out_data) { |
| 244 | ASSERT_OR_EXECUTE(did_handshake, { return ResultInternalError; }); | 244 | ASSERT_OR_EXECUTE(did_handshake, { return ResultInternalError; }); |
| 245 | size_t actual_size{}; | 245 | size_t actual_size{}; |
| 246 | Result res = backend->Read(&actual_size, *out_data); | 246 | Result res = backend->Read(&actual_size, *out_data); |
| @@ -326,8 +326,8 @@ private: | |||
| 326 | } | 326 | } |
| 327 | 327 | ||
| 328 | void Read(HLERequestContext& ctx) { | 328 | void Read(HLERequestContext& ctx) { |
| 329 | std::vector<u8> output_bytes; | 329 | std::vector<u8> output_bytes(ctx.GetWriteBufferSize()); |
| 330 | const Result res = ReadImpl(&output_bytes, ctx.GetWriteBufferSize()); | 330 | const Result res = ReadImpl(&output_bytes); |
| 331 | IPC::ResponseBuilder rb{ctx, 3}; | 331 | IPC::ResponseBuilder rb{ctx, 3}; |
| 332 | rb.Push(res); | 332 | rb.Push(res); |
| 333 | if (res == ResultSuccess) { | 333 | if (res == ResultSuccess) { |
diff --git a/src/core/memory/cheat_engine.cpp b/src/core/memory/cheat_engine.cpp index db30ba598..3fc4024dc 100644 --- a/src/core/memory/cheat_engine.cpp +++ b/src/core/memory/cheat_engine.cpp | |||
| @@ -62,7 +62,7 @@ u64 StandardVmCallbacks::HidKeysDown() { | |||
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | const auto applet_resource = hid->GetResourceManager(); | 64 | const auto applet_resource = hid->GetResourceManager(); |
| 65 | if (applet_resource == nullptr) { | 65 | if (applet_resource == nullptr || applet_resource->GetNpad() == nullptr) { |
| 66 | LOG_WARNING(CheatEngine, | 66 | LOG_WARNING(CheatEngine, |
| 67 | "Attempted to read input state, but applet resource is not initialized!"); | 67 | "Attempted to read input state, but applet resource is not initialized!"); |
| 68 | return 0; | 68 | return 0; |
diff --git a/src/tests/video_core/memory_tracker.cpp b/src/tests/video_core/memory_tracker.cpp index 618793668..2dbff21af 100644 --- a/src/tests/video_core/memory_tracker.cpp +++ b/src/tests/video_core/memory_tracker.cpp | |||
| @@ -23,13 +23,13 @@ constexpr VAddr c = 16 * HIGH_PAGE_SIZE; | |||
| 23 | 23 | ||
| 24 | class RasterizerInterface { | 24 | class RasterizerInterface { |
| 25 | public: | 25 | public: |
| 26 | void UpdatePagesCachedCount(VAddr addr, u64 size, int delta) { | 26 | void UpdatePagesCachedCount(VAddr addr, u64 size, bool cache) { |
| 27 | const u64 page_start{addr >> Core::Memory::YUZU_PAGEBITS}; | 27 | const u64 page_start{addr >> Core::Memory::YUZU_PAGEBITS}; |
| 28 | const u64 page_end{(addr + size + Core::Memory::YUZU_PAGESIZE - 1) >> | 28 | const u64 page_end{(addr + size + Core::Memory::YUZU_PAGESIZE - 1) >> |
| 29 | Core::Memory::YUZU_PAGEBITS}; | 29 | Core::Memory::YUZU_PAGEBITS}; |
| 30 | for (u64 page = page_start; page < page_end; ++page) { | 30 | for (u64 page = page_start; page < page_end; ++page) { |
| 31 | int& value = page_table[page]; | 31 | int& value = page_table[page]; |
| 32 | value += delta; | 32 | value += (cache ? 1 : -1); |
| 33 | if (value < 0) { | 33 | if (value < 0) { |
| 34 | throw std::logic_error{"negative page"}; | 34 | throw std::logic_error{"negative page"}; |
| 35 | } | 35 | } |
| @@ -546,4 +546,4 @@ TEST_CASE("MemoryTracker: Cached write downloads") { | |||
| 546 | REQUIRE(!memory_track->IsRegionGpuModified(c + PAGE, PAGE)); | 546 | REQUIRE(!memory_track->IsRegionGpuModified(c + PAGE, PAGE)); |
| 547 | memory_track->MarkRegionAsCpuModified(c, WORD); | 547 | memory_track->MarkRegionAsCpuModified(c, WORD); |
| 548 | REQUIRE(rasterizer.Count() == 0); | 548 | REQUIRE(rasterizer.Count() == 0); |
| 549 | } \ No newline at end of file | 549 | } |
diff --git a/src/video_core/buffer_cache/word_manager.h b/src/video_core/buffer_cache/word_manager.h index a336bde41..95b752055 100644 --- a/src/video_core/buffer_cache/word_manager.h +++ b/src/video_core/buffer_cache/word_manager.h | |||
| @@ -473,7 +473,7 @@ private: | |||
| 473 | VAddr addr = cpu_addr + word_index * BYTES_PER_WORD; | 473 | VAddr addr = cpu_addr + word_index * BYTES_PER_WORD; |
| 474 | IteratePages(changed_bits, [&](size_t offset, size_t size) { | 474 | IteratePages(changed_bits, [&](size_t offset, size_t size) { |
| 475 | rasterizer->UpdatePagesCachedCount(addr + offset * BYTES_PER_PAGE, | 475 | rasterizer->UpdatePagesCachedCount(addr + offset * BYTES_PER_PAGE, |
| 476 | size * BYTES_PER_PAGE, add_to_rasterizer ? 1 : -1); | 476 | size * BYTES_PER_PAGE, add_to_rasterizer); |
| 477 | }); | 477 | }); |
| 478 | } | 478 | } |
| 479 | 479 | ||
diff --git a/src/video_core/rasterizer_accelerated.cpp b/src/video_core/rasterizer_accelerated.cpp index f200a650f..3c9477f6e 100644 --- a/src/video_core/rasterizer_accelerated.cpp +++ b/src/video_core/rasterizer_accelerated.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #include <atomic> | 4 | #include <atomic> |
| 5 | 5 | ||
| 6 | #include "common/alignment.h" | ||
| 6 | #include "common/assert.h" | 7 | #include "common/assert.h" |
| 7 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 8 | #include "common/div_ceil.h" | 9 | #include "common/div_ceil.h" |
| @@ -11,61 +12,65 @@ | |||
| 11 | 12 | ||
| 12 | namespace VideoCore { | 13 | namespace VideoCore { |
| 13 | 14 | ||
| 15 | static constexpr u16 IdentityValue = 1; | ||
| 16 | |||
| 14 | using namespace Core::Memory; | 17 | using namespace Core::Memory; |
| 15 | 18 | ||
| 16 | RasterizerAccelerated::RasterizerAccelerated(Memory& cpu_memory_) | 19 | RasterizerAccelerated::RasterizerAccelerated(Memory& cpu_memory_) : map{}, cpu_memory{cpu_memory_} { |
| 17 | : cached_pages(std::make_unique<CachedPages>()), cpu_memory{cpu_memory_} {} | 20 | // We are tracking CPU memory, which cannot map more than 39 bits. |
| 21 | const VAddr start_address = 0; | ||
| 22 | const VAddr end_address = (1ULL << 39); | ||
| 23 | const IntervalType address_space_interval(start_address, end_address); | ||
| 24 | const auto value = std::make_pair(address_space_interval, IdentityValue); | ||
| 25 | |||
| 26 | map.add(value); | ||
| 27 | } | ||
| 18 | 28 | ||
| 19 | RasterizerAccelerated::~RasterizerAccelerated() = default; | 29 | RasterizerAccelerated::~RasterizerAccelerated() = default; |
| 20 | 30 | ||
| 21 | void RasterizerAccelerated::UpdatePagesCachedCount(VAddr addr, u64 size, int delta) { | 31 | void RasterizerAccelerated::UpdatePagesCachedCount(VAddr addr, u64 size, bool cache) { |
| 22 | u64 uncache_begin = 0; | 32 | std::scoped_lock lk{map_lock}; |
| 23 | u64 cache_begin = 0; | ||
| 24 | u64 uncache_bytes = 0; | ||
| 25 | u64 cache_bytes = 0; | ||
| 26 | |||
| 27 | std::atomic_thread_fence(std::memory_order_acquire); | ||
| 28 | const u64 page_end = Common::DivCeil(addr + size, YUZU_PAGESIZE); | ||
| 29 | for (u64 page = addr >> YUZU_PAGEBITS; page != page_end; ++page) { | ||
| 30 | std::atomic_uint16_t& count = cached_pages->at(page >> 2).Count(page); | ||
| 31 | |||
| 32 | if (delta > 0) { | ||
| 33 | ASSERT_MSG(count.load(std::memory_order::relaxed) < UINT16_MAX, "Count may overflow!"); | ||
| 34 | } else if (delta < 0) { | ||
| 35 | ASSERT_MSG(count.load(std::memory_order::relaxed) > 0, "Count may underflow!"); | ||
| 36 | } else { | ||
| 37 | ASSERT_MSG(false, "Delta must be non-zero!"); | ||
| 38 | } | ||
| 39 | 33 | ||
| 40 | // Adds or subtracts 1, as count is a unsigned 8-bit value | 34 | // Align sizes. |
| 41 | count.fetch_add(static_cast<u16>(delta), std::memory_order_release); | 35 | addr = Common::AlignDown(addr, YUZU_PAGESIZE); |
| 42 | 36 | size = Common::AlignUp(size, YUZU_PAGESIZE); | |
| 43 | // Assume delta is either -1 or 1 | 37 | |
| 44 | if (count.load(std::memory_order::relaxed) == 0) { | 38 | // Declare the overall interval we are going to operate on. |
| 45 | if (uncache_bytes == 0) { | 39 | const VAddr start_address = addr; |
| 46 | uncache_begin = page; | 40 | const VAddr end_address = addr + size; |
| 47 | } | 41 | const IntervalType modification_range(start_address, end_address); |
| 48 | uncache_bytes += YUZU_PAGESIZE; | 42 | |
| 49 | } else if (uncache_bytes > 0) { | 43 | // Find the boundaries of where to iterate. |
| 50 | cpu_memory.RasterizerMarkRegionCached(uncache_begin << YUZU_PAGEBITS, uncache_bytes, | 44 | const auto lower = map.lower_bound(modification_range); |
| 51 | false); | 45 | const auto upper = map.upper_bound(modification_range); |
| 52 | uncache_bytes = 0; | 46 | |
| 53 | } | 47 | // Iterate over the contained intervals. |
| 54 | if (count.load(std::memory_order::relaxed) == 1 && delta > 0) { | 48 | for (auto it = lower; it != upper; it++) { |
| 55 | if (cache_bytes == 0) { | 49 | // Intersect interval range with modification range. |
| 56 | cache_begin = page; | 50 | const auto current_range = modification_range & it->first; |
| 57 | } | 51 | |
| 58 | cache_bytes += YUZU_PAGESIZE; | 52 | // Calculate the address and size to operate over. |
| 59 | } else if (cache_bytes > 0) { | 53 | const auto current_addr = current_range.lower(); |
| 60 | cpu_memory.RasterizerMarkRegionCached(cache_begin << YUZU_PAGEBITS, cache_bytes, true); | 54 | const auto current_size = current_range.upper() - current_addr; |
| 61 | cache_bytes = 0; | 55 | |
| 56 | // Get the current value of the range. | ||
| 57 | const auto value = it->second; | ||
| 58 | |||
| 59 | if (cache && value == IdentityValue) { | ||
| 60 | // If we are going to cache, and the value is not yet referenced, then cache this range. | ||
| 61 | cpu_memory.RasterizerMarkRegionCached(current_addr, current_size, true); | ||
| 62 | } else if (!cache && value == IdentityValue + 1) { | ||
| 63 | // If we are going to uncache, and this is the last reference, then uncache this range. | ||
| 64 | cpu_memory.RasterizerMarkRegionCached(current_addr, current_size, false); | ||
| 62 | } | 65 | } |
| 63 | } | 66 | } |
| 64 | if (uncache_bytes > 0) { | 67 | |
| 65 | cpu_memory.RasterizerMarkRegionCached(uncache_begin << YUZU_PAGEBITS, uncache_bytes, false); | 68 | // Update the set. |
| 66 | } | 69 | const auto value = std::make_pair(modification_range, IdentityValue); |
| 67 | if (cache_bytes > 0) { | 70 | if (cache) { |
| 68 | cpu_memory.RasterizerMarkRegionCached(cache_begin << YUZU_PAGEBITS, cache_bytes, true); | 71 | map.add(value); |
| 72 | } else { | ||
| 73 | map.subtract(value); | ||
| 69 | } | 74 | } |
| 70 | } | 75 | } |
| 71 | 76 | ||
diff --git a/src/video_core/rasterizer_accelerated.h b/src/video_core/rasterizer_accelerated.h index e6c0ea87a..f1968f186 100644 --- a/src/video_core/rasterizer_accelerated.h +++ b/src/video_core/rasterizer_accelerated.h | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <array> | 6 | #include <mutex> |
| 7 | #include <atomic> | 7 | #include <boost/icl/interval_map.hpp> |
| 8 | 8 | ||
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "video_core/rasterizer_interface.h" | 10 | #include "video_core/rasterizer_interface.h" |
| @@ -21,28 +21,17 @@ public: | |||
| 21 | explicit RasterizerAccelerated(Core::Memory::Memory& cpu_memory_); | 21 | explicit RasterizerAccelerated(Core::Memory::Memory& cpu_memory_); |
| 22 | ~RasterizerAccelerated() override; | 22 | ~RasterizerAccelerated() override; |
| 23 | 23 | ||
| 24 | void UpdatePagesCachedCount(VAddr addr, u64 size, int delta) override; | 24 | void UpdatePagesCachedCount(VAddr addr, u64 size, bool cache) override; |
| 25 | 25 | ||
| 26 | private: | 26 | private: |
| 27 | class CacheEntry final { | 27 | using PageIndex = VAddr; |
| 28 | public: | 28 | using PageReferenceCount = u16; |
| 29 | CacheEntry() = default; | ||
| 30 | 29 | ||
| 31 | std::atomic_uint16_t& Count(std::size_t page) { | 30 | using IntervalMap = boost::icl::interval_map<PageIndex, PageReferenceCount>; |
| 32 | return values[page & 3]; | 31 | using IntervalType = IntervalMap::interval_type; |
| 33 | } | ||
| 34 | 32 | ||
| 35 | const std::atomic_uint16_t& Count(std::size_t page) const { | 33 | IntervalMap map; |
| 36 | return values[page & 3]; | 34 | std::mutex map_lock; |
| 37 | } | ||
| 38 | |||
| 39 | private: | ||
| 40 | std::array<std::atomic_uint16_t, 4> values{}; | ||
| 41 | }; | ||
| 42 | static_assert(sizeof(CacheEntry) == 8, "CacheEntry should be 8 bytes!"); | ||
| 43 | |||
| 44 | using CachedPages = std::array<CacheEntry, 0x2000000>; | ||
| 45 | std::unique_ptr<CachedPages> cached_pages; | ||
| 46 | Core::Memory::Memory& cpu_memory; | 35 | Core::Memory::Memory& cpu_memory; |
| 47 | }; | 36 | }; |
| 48 | 37 | ||
diff --git a/src/video_core/rasterizer_interface.h b/src/video_core/rasterizer_interface.h index af1469147..fd42d26b5 100644 --- a/src/video_core/rasterizer_interface.h +++ b/src/video_core/rasterizer_interface.h | |||
| @@ -162,7 +162,7 @@ public: | |||
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | /// Increase/decrease the number of object in pages touching the specified region | 164 | /// Increase/decrease the number of object in pages touching the specified region |
| 165 | virtual void UpdatePagesCachedCount(VAddr addr, u64 size, int delta) {} | 165 | virtual void UpdatePagesCachedCount(VAddr addr, u64 size, bool cache) {} |
| 166 | 166 | ||
| 167 | /// Initialize disk cached resources for the game being emulated | 167 | /// Initialize disk cached resources for the game being emulated |
| 168 | virtual void LoadDiskResources(u64 title_id, std::stop_token stop_loading, | 168 | virtual void LoadDiskResources(u64 title_id, std::stop_token stop_loading, |
diff --git a/src/video_core/shader_cache.cpp b/src/video_core/shader_cache.cpp index e81cd031b..a109f9cbe 100644 --- a/src/video_core/shader_cache.cpp +++ b/src/video_core/shader_cache.cpp | |||
| @@ -132,7 +132,7 @@ void ShaderCache::Register(std::unique_ptr<ShaderInfo> data, VAddr addr, size_t | |||
| 132 | 132 | ||
| 133 | storage.push_back(std::move(data)); | 133 | storage.push_back(std::move(data)); |
| 134 | 134 | ||
| 135 | rasterizer.UpdatePagesCachedCount(addr, size, 1); | 135 | rasterizer.UpdatePagesCachedCount(addr, size, true); |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | void ShaderCache::InvalidatePagesInRegion(VAddr addr, size_t size) { | 138 | void ShaderCache::InvalidatePagesInRegion(VAddr addr, size_t size) { |
| @@ -209,7 +209,7 @@ void ShaderCache::UnmarkMemory(Entry* entry) { | |||
| 209 | 209 | ||
| 210 | const VAddr addr = entry->addr_start; | 210 | const VAddr addr = entry->addr_start; |
| 211 | const size_t size = entry->addr_end - addr; | 211 | const size_t size = entry->addr_end - addr; |
| 212 | rasterizer.UpdatePagesCachedCount(addr, size, -1); | 212 | rasterizer.UpdatePagesCachedCount(addr, size, false); |
| 213 | } | 213 | } |
| 214 | 214 | ||
| 215 | void ShaderCache::RemoveShadersFromStorage(std::span<ShaderInfo*> removed_shaders) { | 215 | void ShaderCache::RemoveShadersFromStorage(std::span<ShaderInfo*> removed_shaders) { |
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 0d5a1709f..d7941f6a4 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -2080,7 +2080,7 @@ void TextureCache<P>::TrackImage(ImageBase& image, ImageId image_id) { | |||
| 2080 | ASSERT(False(image.flags & ImageFlagBits::Tracked)); | 2080 | ASSERT(False(image.flags & ImageFlagBits::Tracked)); |
| 2081 | image.flags |= ImageFlagBits::Tracked; | 2081 | image.flags |= ImageFlagBits::Tracked; |
| 2082 | if (False(image.flags & ImageFlagBits::Sparse)) { | 2082 | if (False(image.flags & ImageFlagBits::Sparse)) { |
| 2083 | rasterizer.UpdatePagesCachedCount(image.cpu_addr, image.guest_size_bytes, 1); | 2083 | rasterizer.UpdatePagesCachedCount(image.cpu_addr, image.guest_size_bytes, true); |
| 2084 | return; | 2084 | return; |
| 2085 | } | 2085 | } |
| 2086 | if (True(image.flags & ImageFlagBits::Registered)) { | 2086 | if (True(image.flags & ImageFlagBits::Registered)) { |
| @@ -2091,13 +2091,13 @@ void TextureCache<P>::TrackImage(ImageBase& image, ImageId image_id) { | |||
| 2091 | const auto& map = slot_map_views[map_view_id]; | 2091 | const auto& map = slot_map_views[map_view_id]; |
| 2092 | const VAddr cpu_addr = map.cpu_addr; | 2092 | const VAddr cpu_addr = map.cpu_addr; |
| 2093 | const std::size_t size = map.size; | 2093 | const std::size_t size = map.size; |
| 2094 | rasterizer.UpdatePagesCachedCount(cpu_addr, size, 1); | 2094 | rasterizer.UpdatePagesCachedCount(cpu_addr, size, true); |
| 2095 | } | 2095 | } |
| 2096 | return; | 2096 | return; |
| 2097 | } | 2097 | } |
| 2098 | ForEachSparseSegment(image, | 2098 | ForEachSparseSegment(image, |
| 2099 | [this]([[maybe_unused]] GPUVAddr gpu_addr, VAddr cpu_addr, size_t size) { | 2099 | [this]([[maybe_unused]] GPUVAddr gpu_addr, VAddr cpu_addr, size_t size) { |
| 2100 | rasterizer.UpdatePagesCachedCount(cpu_addr, size, 1); | 2100 | rasterizer.UpdatePagesCachedCount(cpu_addr, size, true); |
| 2101 | }); | 2101 | }); |
| 2102 | } | 2102 | } |
| 2103 | 2103 | ||
| @@ -2106,7 +2106,7 @@ void TextureCache<P>::UntrackImage(ImageBase& image, ImageId image_id) { | |||
| 2106 | ASSERT(True(image.flags & ImageFlagBits::Tracked)); | 2106 | ASSERT(True(image.flags & ImageFlagBits::Tracked)); |
| 2107 | image.flags &= ~ImageFlagBits::Tracked; | 2107 | image.flags &= ~ImageFlagBits::Tracked; |
| 2108 | if (False(image.flags & ImageFlagBits::Sparse)) { | 2108 | if (False(image.flags & ImageFlagBits::Sparse)) { |
| 2109 | rasterizer.UpdatePagesCachedCount(image.cpu_addr, image.guest_size_bytes, -1); | 2109 | rasterizer.UpdatePagesCachedCount(image.cpu_addr, image.guest_size_bytes, false); |
| 2110 | return; | 2110 | return; |
| 2111 | } | 2111 | } |
| 2112 | ASSERT(True(image.flags & ImageFlagBits::Registered)); | 2112 | ASSERT(True(image.flags & ImageFlagBits::Registered)); |
| @@ -2117,7 +2117,7 @@ void TextureCache<P>::UntrackImage(ImageBase& image, ImageId image_id) { | |||
| 2117 | const auto& map = slot_map_views[map_view_id]; | 2117 | const auto& map = slot_map_views[map_view_id]; |
| 2118 | const VAddr cpu_addr = map.cpu_addr; | 2118 | const VAddr cpu_addr = map.cpu_addr; |
| 2119 | const std::size_t size = map.size; | 2119 | const std::size_t size = map.size; |
| 2120 | rasterizer.UpdatePagesCachedCount(cpu_addr, size, -1); | 2120 | rasterizer.UpdatePagesCachedCount(cpu_addr, size, false); |
| 2121 | } | 2121 | } |
| 2122 | } | 2122 | } |
| 2123 | 2123 | ||
diff --git a/src/yuzu/applets/qt_profile_select.cpp b/src/yuzu/applets/qt_profile_select.cpp index 1f3f23038..79162a491 100644 --- a/src/yuzu/applets/qt_profile_select.cpp +++ b/src/yuzu/applets/qt_profile_select.cpp | |||
| @@ -14,6 +14,8 @@ | |||
| 14 | #include "common/fs/path_util.h" | 14 | #include "common/fs/path_util.h" |
| 15 | #include "common/string_util.h" | 15 | #include "common/string_util.h" |
| 16 | #include "core/constants.h" | 16 | #include "core/constants.h" |
| 17 | #include "core/core.h" | ||
| 18 | #include "core/hle/service/acc/profile_manager.h" | ||
| 17 | #include "yuzu/applets/qt_profile_select.h" | 19 | #include "yuzu/applets/qt_profile_select.h" |
| 18 | #include "yuzu/main.h" | 20 | #include "yuzu/main.h" |
| 19 | #include "yuzu/util/controller_navigation.h" | 21 | #include "yuzu/util/controller_navigation.h" |
| @@ -47,9 +49,9 @@ QPixmap GetIcon(Common::UUID uuid) { | |||
| 47 | } // Anonymous namespace | 49 | } // Anonymous namespace |
| 48 | 50 | ||
| 49 | QtProfileSelectionDialog::QtProfileSelectionDialog( | 51 | QtProfileSelectionDialog::QtProfileSelectionDialog( |
| 50 | Core::HID::HIDCore& hid_core, QWidget* parent, | 52 | Core::System& system, QWidget* parent, |
| 51 | const Core::Frontend::ProfileSelectParameters& parameters) | 53 | const Core::Frontend::ProfileSelectParameters& parameters) |
| 52 | : QDialog(parent), profile_manager(std::make_unique<Service::Account::ProfileManager>()) { | 54 | : QDialog(parent), profile_manager{system.GetProfileManager()} { |
| 53 | outer_layout = new QVBoxLayout; | 55 | outer_layout = new QVBoxLayout; |
| 54 | 56 | ||
| 55 | instruction_label = new QLabel(); | 57 | instruction_label = new QLabel(); |
| @@ -68,7 +70,7 @@ QtProfileSelectionDialog::QtProfileSelectionDialog( | |||
| 68 | tree_view = new QTreeView; | 70 | tree_view = new QTreeView; |
| 69 | item_model = new QStandardItemModel(tree_view); | 71 | item_model = new QStandardItemModel(tree_view); |
| 70 | tree_view->setModel(item_model); | 72 | tree_view->setModel(item_model); |
| 71 | controller_navigation = new ControllerNavigation(hid_core, this); | 73 | controller_navigation = new ControllerNavigation(system.HIDCore(), this); |
| 72 | 74 | ||
| 73 | tree_view->setAlternatingRowColors(true); | 75 | tree_view->setAlternatingRowColors(true); |
| 74 | tree_view->setSelectionMode(QHeaderView::SingleSelection); | 76 | tree_view->setSelectionMode(QHeaderView::SingleSelection); |
| @@ -106,10 +108,10 @@ QtProfileSelectionDialog::QtProfileSelectionDialog( | |||
| 106 | SelectUser(tree_view->currentIndex()); | 108 | SelectUser(tree_view->currentIndex()); |
| 107 | }); | 109 | }); |
| 108 | 110 | ||
| 109 | const auto& profiles = profile_manager->GetAllUsers(); | 111 | const auto& profiles = profile_manager.GetAllUsers(); |
| 110 | for (const auto& user : profiles) { | 112 | for (const auto& user : profiles) { |
| 111 | Service::Account::ProfileBase profile{}; | 113 | Service::Account::ProfileBase profile{}; |
| 112 | if (!profile_manager->GetProfileBase(user, profile)) | 114 | if (!profile_manager.GetProfileBase(user, profile)) |
| 113 | continue; | 115 | continue; |
| 114 | 116 | ||
| 115 | const auto username = Common::StringFromFixedZeroTerminatedBuffer( | 117 | const auto username = Common::StringFromFixedZeroTerminatedBuffer( |
| @@ -134,7 +136,7 @@ QtProfileSelectionDialog::~QtProfileSelectionDialog() { | |||
| 134 | 136 | ||
| 135 | int QtProfileSelectionDialog::exec() { | 137 | int QtProfileSelectionDialog::exec() { |
| 136 | // Skip profile selection when there's only one. | 138 | // Skip profile selection when there's only one. |
| 137 | if (profile_manager->GetUserCount() == 1) { | 139 | if (profile_manager.GetUserCount() == 1) { |
| 138 | user_index = 0; | 140 | user_index = 0; |
| 139 | return QDialog::Accepted; | 141 | return QDialog::Accepted; |
| 140 | } | 142 | } |
diff --git a/src/yuzu/applets/qt_profile_select.h b/src/yuzu/applets/qt_profile_select.h index 99056e274..607f1777c 100644 --- a/src/yuzu/applets/qt_profile_select.h +++ b/src/yuzu/applets/qt_profile_select.h | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | #include <QDialog> | 7 | #include <QDialog> |
| 8 | #include <QList> | 8 | #include <QList> |
| 9 | #include "core/frontend/applets/profile_select.h" | 9 | #include "core/frontend/applets/profile_select.h" |
| 10 | #include "core/hle/service/acc/profile_manager.h" | ||
| 11 | 10 | ||
| 12 | class ControllerNavigation; | 11 | class ControllerNavigation; |
| 13 | class GMainWindow; | 12 | class GMainWindow; |
| @@ -20,15 +19,19 @@ class QStandardItemModel; | |||
| 20 | class QTreeView; | 19 | class QTreeView; |
| 21 | class QVBoxLayout; | 20 | class QVBoxLayout; |
| 22 | 21 | ||
| 23 | namespace Core::HID { | 22 | namespace Core { |
| 24 | class HIDCore; | 23 | class System; |
| 25 | } // namespace Core::HID | 24 | } |
| 25 | |||
| 26 | namespace Service::Account { | ||
| 27 | class ProfileManager; | ||
| 28 | } | ||
| 26 | 29 | ||
| 27 | class QtProfileSelectionDialog final : public QDialog { | 30 | class QtProfileSelectionDialog final : public QDialog { |
| 28 | Q_OBJECT | 31 | Q_OBJECT |
| 29 | 32 | ||
| 30 | public: | 33 | public: |
| 31 | explicit QtProfileSelectionDialog(Core::HID::HIDCore& hid_core, QWidget* parent, | 34 | explicit QtProfileSelectionDialog(Core::System& system, QWidget* parent, |
| 32 | const Core::Frontend::ProfileSelectParameters& parameters); | 35 | const Core::Frontend::ProfileSelectParameters& parameters); |
| 33 | ~QtProfileSelectionDialog() override; | 36 | ~QtProfileSelectionDialog() override; |
| 34 | 37 | ||
| @@ -58,7 +61,7 @@ private: | |||
| 58 | QScrollArea* scroll_area; | 61 | QScrollArea* scroll_area; |
| 59 | QDialogButtonBox* buttons; | 62 | QDialogButtonBox* buttons; |
| 60 | 63 | ||
| 61 | std::unique_ptr<Service::Account::ProfileManager> profile_manager; | 64 | Service::Account::ProfileManager& profile_manager; |
| 62 | ControllerNavigation* controller_navigation = nullptr; | 65 | ControllerNavigation* controller_navigation = nullptr; |
| 63 | }; | 66 | }; |
| 64 | 67 | ||
diff --git a/src/yuzu/configuration/configure_debug.ui b/src/yuzu/configuration/configure_debug.ui index 22b51f39c..d842b0135 100644 --- a/src/yuzu/configuration/configure_debug.ui +++ b/src/yuzu/configuration/configure_debug.ui | |||
| @@ -381,7 +381,7 @@ | |||
| 381 | <item row="5" column="0"> | 381 | <item row="5" column="0"> |
| 382 | <widget class="QCheckBox" name="disable_buffer_reorder"> | 382 | <widget class="QCheckBox" name="disable_buffer_reorder"> |
| 383 | <property name="toolTip"> | 383 | <property name="toolTip"> |
| 384 | <string><html><head/><body><p>When checked, disables reording of mapped memory uploads which allows to associate uploads with specific draws. May reduce performance in some cases.</p></body></html></string> | 384 | <string><html><head/><body><p>When checked, disables reordering of mapped memory uploads which allows to associate uploads with specific draws. May reduce performance in some cases.</p></body></html></string> |
| 385 | </property> | 385 | </property> |
| 386 | <property name="text"> | 386 | <property name="text"> |
| 387 | <string>Disable Buffer Reorder</string> | 387 | <string>Disable Buffer Reorder</string> |
diff --git a/src/yuzu/configuration/configure_profile_manager.cpp b/src/yuzu/configuration/configure_profile_manager.cpp index 6d2219bf5..fa5f383d6 100644 --- a/src/yuzu/configuration/configure_profile_manager.cpp +++ b/src/yuzu/configuration/configure_profile_manager.cpp | |||
| @@ -76,9 +76,9 @@ QString GetProfileUsernameFromUser(QWidget* parent, const QString& description_t | |||
| 76 | } | 76 | } |
| 77 | } // Anonymous namespace | 77 | } // Anonymous namespace |
| 78 | 78 | ||
| 79 | ConfigureProfileManager::ConfigureProfileManager(const Core::System& system_, QWidget* parent) | 79 | ConfigureProfileManager::ConfigureProfileManager(Core::System& system_, QWidget* parent) |
| 80 | : QWidget(parent), ui{std::make_unique<Ui::ConfigureProfileManager>()}, | 80 | : QWidget(parent), ui{std::make_unique<Ui::ConfigureProfileManager>()}, |
| 81 | profile_manager(std::make_unique<Service::Account::ProfileManager>()), system{system_} { | 81 | profile_manager{system_.GetProfileManager()}, system{system_} { |
| 82 | ui->setupUi(this); | 82 | ui->setupUi(this); |
| 83 | 83 | ||
| 84 | tree_view = new QTreeView; | 84 | tree_view = new QTreeView; |
| @@ -149,10 +149,10 @@ void ConfigureProfileManager::SetConfiguration() { | |||
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | void ConfigureProfileManager::PopulateUserList() { | 151 | void ConfigureProfileManager::PopulateUserList() { |
| 152 | const auto& profiles = profile_manager->GetAllUsers(); | 152 | const auto& profiles = profile_manager.GetAllUsers(); |
| 153 | for (const auto& user : profiles) { | 153 | for (const auto& user : profiles) { |
| 154 | Service::Account::ProfileBase profile{}; | 154 | Service::Account::ProfileBase profile{}; |
| 155 | if (!profile_manager->GetProfileBase(user, profile)) | 155 | if (!profile_manager.GetProfileBase(user, profile)) |
| 156 | continue; | 156 | continue; |
| 157 | 157 | ||
| 158 | const auto username = Common::StringFromFixedZeroTerminatedBuffer( | 158 | const auto username = Common::StringFromFixedZeroTerminatedBuffer( |
| @@ -167,11 +167,11 @@ void ConfigureProfileManager::PopulateUserList() { | |||
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | void ConfigureProfileManager::UpdateCurrentUser() { | 169 | void ConfigureProfileManager::UpdateCurrentUser() { |
| 170 | ui->pm_add->setEnabled(profile_manager->GetUserCount() < Service::Account::MAX_USERS); | 170 | ui->pm_add->setEnabled(profile_manager.GetUserCount() < Service::Account::MAX_USERS); |
| 171 | 171 | ||
| 172 | const auto& current_user = profile_manager->GetUser(Settings::values.current_user.GetValue()); | 172 | const auto& current_user = profile_manager.GetUser(Settings::values.current_user.GetValue()); |
| 173 | ASSERT(current_user); | 173 | ASSERT(current_user); |
| 174 | const auto username = GetAccountUsername(*profile_manager, *current_user); | 174 | const auto username = GetAccountUsername(profile_manager, *current_user); |
| 175 | 175 | ||
| 176 | scene->clear(); | 176 | scene->clear(); |
| 177 | scene->addPixmap( | 177 | scene->addPixmap( |
| @@ -187,11 +187,11 @@ void ConfigureProfileManager::ApplyConfiguration() { | |||
| 187 | 187 | ||
| 188 | void ConfigureProfileManager::SelectUser(const QModelIndex& index) { | 188 | void ConfigureProfileManager::SelectUser(const QModelIndex& index) { |
| 189 | Settings::values.current_user = | 189 | Settings::values.current_user = |
| 190 | std::clamp<s32>(index.row(), 0, static_cast<s32>(profile_manager->GetUserCount() - 1)); | 190 | std::clamp<s32>(index.row(), 0, static_cast<s32>(profile_manager.GetUserCount() - 1)); |
| 191 | 191 | ||
| 192 | UpdateCurrentUser(); | 192 | UpdateCurrentUser(); |
| 193 | 193 | ||
| 194 | ui->pm_remove->setEnabled(profile_manager->GetUserCount() >= 2); | 194 | ui->pm_remove->setEnabled(profile_manager.GetUserCount() >= 2); |
| 195 | ui->pm_rename->setEnabled(true); | 195 | ui->pm_rename->setEnabled(true); |
| 196 | ui->pm_set_image->setEnabled(true); | 196 | ui->pm_set_image->setEnabled(true); |
| 197 | } | 197 | } |
| @@ -204,18 +204,18 @@ void ConfigureProfileManager::AddUser() { | |||
| 204 | } | 204 | } |
| 205 | 205 | ||
| 206 | const auto uuid = Common::UUID::MakeRandom(); | 206 | const auto uuid = Common::UUID::MakeRandom(); |
| 207 | profile_manager->CreateNewUser(uuid, username.toStdString()); | 207 | profile_manager.CreateNewUser(uuid, username.toStdString()); |
| 208 | 208 | ||
| 209 | item_model->appendRow(new QStandardItem{GetIcon(uuid), FormatUserEntryText(username, uuid)}); | 209 | item_model->appendRow(new QStandardItem{GetIcon(uuid), FormatUserEntryText(username, uuid)}); |
| 210 | } | 210 | } |
| 211 | 211 | ||
| 212 | void ConfigureProfileManager::RenameUser() { | 212 | void ConfigureProfileManager::RenameUser() { |
| 213 | const auto user = tree_view->currentIndex().row(); | 213 | const auto user = tree_view->currentIndex().row(); |
| 214 | const auto uuid = profile_manager->GetUser(user); | 214 | const auto uuid = profile_manager.GetUser(user); |
| 215 | ASSERT(uuid); | 215 | ASSERT(uuid); |
| 216 | 216 | ||
| 217 | Service::Account::ProfileBase profile{}; | 217 | Service::Account::ProfileBase profile{}; |
| 218 | if (!profile_manager->GetProfileBase(*uuid, profile)) | 218 | if (!profile_manager.GetProfileBase(*uuid, profile)) |
| 219 | return; | 219 | return; |
| 220 | 220 | ||
| 221 | const auto new_username = GetProfileUsernameFromUser(this, tr("Enter a new username:")); | 221 | const auto new_username = GetProfileUsernameFromUser(this, tr("Enter a new username:")); |
| @@ -227,7 +227,7 @@ void ConfigureProfileManager::RenameUser() { | |||
| 227 | std::fill(profile.username.begin(), profile.username.end(), '\0'); | 227 | std::fill(profile.username.begin(), profile.username.end(), '\0'); |
| 228 | std::copy(username_std.begin(), username_std.end(), profile.username.begin()); | 228 | std::copy(username_std.begin(), username_std.end(), profile.username.begin()); |
| 229 | 229 | ||
| 230 | profile_manager->SetProfileBase(*uuid, profile); | 230 | profile_manager.SetProfileBase(*uuid, profile); |
| 231 | 231 | ||
| 232 | item_model->setItem( | 232 | item_model->setItem( |
| 233 | user, 0, | 233 | user, 0, |
| @@ -238,9 +238,9 @@ void ConfigureProfileManager::RenameUser() { | |||
| 238 | 238 | ||
| 239 | void ConfigureProfileManager::ConfirmDeleteUser() { | 239 | void ConfigureProfileManager::ConfirmDeleteUser() { |
| 240 | const auto index = tree_view->currentIndex().row(); | 240 | const auto index = tree_view->currentIndex().row(); |
| 241 | const auto uuid = profile_manager->GetUser(index); | 241 | const auto uuid = profile_manager.GetUser(index); |
| 242 | ASSERT(uuid); | 242 | ASSERT(uuid); |
| 243 | const auto username = GetAccountUsername(*profile_manager, *uuid); | 243 | const auto username = GetAccountUsername(profile_manager, *uuid); |
| 244 | 244 | ||
| 245 | confirm_dialog->SetInfo(username, *uuid, [this, uuid]() { DeleteUser(*uuid); }); | 245 | confirm_dialog->SetInfo(username, *uuid, [this, uuid]() { DeleteUser(*uuid); }); |
| 246 | confirm_dialog->show(); | 246 | confirm_dialog->show(); |
| @@ -252,7 +252,7 @@ void ConfigureProfileManager::DeleteUser(const Common::UUID& uuid) { | |||
| 252 | } | 252 | } |
| 253 | UpdateCurrentUser(); | 253 | UpdateCurrentUser(); |
| 254 | 254 | ||
| 255 | if (!profile_manager->RemoveUser(uuid)) { | 255 | if (!profile_manager.RemoveUser(uuid)) { |
| 256 | return; | 256 | return; |
| 257 | } | 257 | } |
| 258 | 258 | ||
| @@ -265,7 +265,7 @@ void ConfigureProfileManager::DeleteUser(const Common::UUID& uuid) { | |||
| 265 | 265 | ||
| 266 | void ConfigureProfileManager::SetUserImage() { | 266 | void ConfigureProfileManager::SetUserImage() { |
| 267 | const auto index = tree_view->currentIndex().row(); | 267 | const auto index = tree_view->currentIndex().row(); |
| 268 | const auto uuid = profile_manager->GetUser(index); | 268 | const auto uuid = profile_manager.GetUser(index); |
| 269 | ASSERT(uuid); | 269 | ASSERT(uuid); |
| 270 | 270 | ||
| 271 | const auto file = QFileDialog::getOpenFileName(this, tr("Select User Image"), QString(), | 271 | const auto file = QFileDialog::getOpenFileName(this, tr("Select User Image"), QString(), |
| @@ -317,7 +317,7 @@ void ConfigureProfileManager::SetUserImage() { | |||
| 317 | } | 317 | } |
| 318 | } | 318 | } |
| 319 | 319 | ||
| 320 | const auto username = GetAccountUsername(*profile_manager, *uuid); | 320 | const auto username = GetAccountUsername(profile_manager, *uuid); |
| 321 | item_model->setItem(index, 0, | 321 | item_model->setItem(index, 0, |
| 322 | new QStandardItem{GetIcon(*uuid), FormatUserEntryText(username, *uuid)}); | 322 | new QStandardItem{GetIcon(*uuid), FormatUserEntryText(username, *uuid)}); |
| 323 | UpdateCurrentUser(); | 323 | UpdateCurrentUser(); |
diff --git a/src/yuzu/configuration/configure_profile_manager.h b/src/yuzu/configuration/configure_profile_manager.h index c4b1a334e..39560fdd9 100644 --- a/src/yuzu/configuration/configure_profile_manager.h +++ b/src/yuzu/configuration/configure_profile_manager.h | |||
| @@ -52,7 +52,7 @@ class ConfigureProfileManager : public QWidget { | |||
| 52 | Q_OBJECT | 52 | Q_OBJECT |
| 53 | 53 | ||
| 54 | public: | 54 | public: |
| 55 | explicit ConfigureProfileManager(const Core::System& system_, QWidget* parent = nullptr); | 55 | explicit ConfigureProfileManager(Core::System& system_, QWidget* parent = nullptr); |
| 56 | ~ConfigureProfileManager() override; | 56 | ~ConfigureProfileManager() override; |
| 57 | 57 | ||
| 58 | void ApplyConfiguration(); | 58 | void ApplyConfiguration(); |
| @@ -85,7 +85,6 @@ private: | |||
| 85 | std::unique_ptr<Ui::ConfigureProfileManager> ui; | 85 | std::unique_ptr<Ui::ConfigureProfileManager> ui; |
| 86 | bool enabled = false; | 86 | bool enabled = false; |
| 87 | 87 | ||
| 88 | std::unique_ptr<Service::Account::ProfileManager> profile_manager; | 88 | Service::Account::ProfileManager& profile_manager; |
| 89 | |||
| 90 | const Core::System& system; | 89 | const Core::System& system; |
| 91 | }; | 90 | }; |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index b056c3717..f31ed7ebb 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -346,7 +346,7 @@ GMainWindow::GMainWindow(std::unique_ptr<QtConfig> config_, bool has_broken_vulk | |||
| 346 | SetDiscordEnabled(UISettings::values.enable_discord_presence.GetValue()); | 346 | SetDiscordEnabled(UISettings::values.enable_discord_presence.GetValue()); |
| 347 | discord_rpc->Update(); | 347 | discord_rpc->Update(); |
| 348 | 348 | ||
| 349 | play_time_manager = std::make_unique<PlayTime::PlayTimeManager>(); | 349 | play_time_manager = std::make_unique<PlayTime::PlayTimeManager>(system->GetProfileManager()); |
| 350 | 350 | ||
| 351 | system->GetRoomNetwork().Init(); | 351 | system->GetRoomNetwork().Init(); |
| 352 | 352 | ||
| @@ -526,8 +526,7 @@ GMainWindow::GMainWindow(std::unique_ptr<QtConfig> config_, bool has_broken_vulk | |||
| 526 | continue; | 526 | continue; |
| 527 | } | 527 | } |
| 528 | 528 | ||
| 529 | const Service::Account::ProfileManager manager; | 529 | if (!system->GetProfileManager().UserExistsIndex(selected_user)) { |
| 530 | if (!manager.UserExistsIndex(selected_user)) { | ||
| 531 | LOG_ERROR(Frontend, "Selected user doesn't exist"); | 530 | LOG_ERROR(Frontend, "Selected user doesn't exist"); |
| 532 | continue; | 531 | continue; |
| 533 | } | 532 | } |
| @@ -691,7 +690,7 @@ void GMainWindow::ControllerSelectorRequestExit() { | |||
| 691 | 690 | ||
| 692 | void GMainWindow::ProfileSelectorSelectProfile( | 691 | void GMainWindow::ProfileSelectorSelectProfile( |
| 693 | const Core::Frontend::ProfileSelectParameters& parameters) { | 692 | const Core::Frontend::ProfileSelectParameters& parameters) { |
| 694 | profile_select_applet = new QtProfileSelectionDialog(system->HIDCore(), this, parameters); | 693 | profile_select_applet = new QtProfileSelectionDialog(*system, this, parameters); |
| 695 | SCOPE_EXIT({ | 694 | SCOPE_EXIT({ |
| 696 | profile_select_applet->deleteLater(); | 695 | profile_select_applet->deleteLater(); |
| 697 | profile_select_applet = nullptr; | 696 | profile_select_applet = nullptr; |
| @@ -706,8 +705,8 @@ void GMainWindow::ProfileSelectorSelectProfile( | |||
| 706 | return; | 705 | return; |
| 707 | } | 706 | } |
| 708 | 707 | ||
| 709 | const Service::Account::ProfileManager manager; | 708 | const auto uuid = system->GetProfileManager().GetUser( |
| 710 | const auto uuid = manager.GetUser(static_cast<std::size_t>(profile_select_applet->GetIndex())); | 709 | static_cast<std::size_t>(profile_select_applet->GetIndex())); |
| 711 | if (!uuid.has_value()) { | 710 | if (!uuid.has_value()) { |
| 712 | emit ProfileSelectorFinishedSelection(std::nullopt); | 711 | emit ProfileSelectorFinishedSelection(std::nullopt); |
| 713 | return; | 712 | return; |
| @@ -1856,7 +1855,7 @@ bool GMainWindow::LoadROM(const QString& filename, u64 program_id, std::size_t p | |||
| 1856 | 1855 | ||
| 1857 | bool GMainWindow::SelectAndSetCurrentUser( | 1856 | bool GMainWindow::SelectAndSetCurrentUser( |
| 1858 | const Core::Frontend::ProfileSelectParameters& parameters) { | 1857 | const Core::Frontend::ProfileSelectParameters& parameters) { |
| 1859 | QtProfileSelectionDialog dialog(system->HIDCore(), this, parameters); | 1858 | QtProfileSelectionDialog dialog(*system, this, parameters); |
| 1860 | dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | | 1859 | dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | |
| 1861 | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); | 1860 | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); |
| 1862 | dialog.setWindowModality(Qt::WindowModal); | 1861 | dialog.setWindowModality(Qt::WindowModal); |
| @@ -2271,7 +2270,7 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target | |||
| 2271 | .display_options = {}, | 2270 | .display_options = {}, |
| 2272 | .purpose = Service::AM::Applets::UserSelectionPurpose::General, | 2271 | .purpose = Service::AM::Applets::UserSelectionPurpose::General, |
| 2273 | }; | 2272 | }; |
| 2274 | QtProfileSelectionDialog dialog(system->HIDCore(), this, parameters); | 2273 | QtProfileSelectionDialog dialog(*system, this, parameters); |
| 2275 | dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | | 2274 | dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | |
| 2276 | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); | 2275 | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); |
| 2277 | dialog.setWindowModality(Qt::WindowModal); | 2276 | dialog.setWindowModality(Qt::WindowModal); |
| @@ -2288,8 +2287,8 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target | |||
| 2288 | return; | 2287 | return; |
| 2289 | } | 2288 | } |
| 2290 | 2289 | ||
| 2291 | Service::Account::ProfileManager manager; | 2290 | const auto user_id = |
| 2292 | const auto user_id = manager.GetUser(static_cast<std::size_t>(index)); | 2291 | system->GetProfileManager().GetUser(static_cast<std::size_t>(index)); |
| 2293 | ASSERT(user_id); | 2292 | ASSERT(user_id); |
| 2294 | 2293 | ||
| 2295 | const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath( | 2294 | const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath( |
diff --git a/src/yuzu/multiplayer/lobby.cpp b/src/yuzu/multiplayer/lobby.cpp index 603e9ae3d..41692c05b 100644 --- a/src/yuzu/multiplayer/lobby.cpp +++ b/src/yuzu/multiplayer/lobby.cpp | |||
| @@ -27,9 +27,9 @@ | |||
| 27 | Lobby::Lobby(QWidget* parent, QStandardItemModel* list, | 27 | Lobby::Lobby(QWidget* parent, QStandardItemModel* list, |
| 28 | std::shared_ptr<Core::AnnounceMultiplayerSession> session, Core::System& system_) | 28 | std::shared_ptr<Core::AnnounceMultiplayerSession> session, Core::System& system_) |
| 29 | : QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint), | 29 | : QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint), |
| 30 | ui(std::make_unique<Ui::Lobby>()), announce_multiplayer_session(session), | 30 | ui(std::make_unique<Ui::Lobby>()), |
| 31 | profile_manager(std::make_unique<Service::Account::ProfileManager>()), system{system_}, | 31 | announce_multiplayer_session(session), system{system_}, room_network{ |
| 32 | room_network{system.GetRoomNetwork()} { | 32 | system.GetRoomNetwork()} { |
| 33 | ui->setupUi(this); | 33 | ui->setupUi(this); |
| 34 | 34 | ||
| 35 | // setup the watcher for background connections | 35 | // setup the watcher for background connections |
| @@ -299,14 +299,15 @@ void Lobby::OnRefreshLobby() { | |||
| 299 | } | 299 | } |
| 300 | 300 | ||
| 301 | std::string Lobby::GetProfileUsername() { | 301 | std::string Lobby::GetProfileUsername() { |
| 302 | const auto& current_user = profile_manager->GetUser(Settings::values.current_user.GetValue()); | 302 | const auto& current_user = |
| 303 | system.GetProfileManager().GetUser(Settings::values.current_user.GetValue()); | ||
| 303 | Service::Account::ProfileBase profile{}; | 304 | Service::Account::ProfileBase profile{}; |
| 304 | 305 | ||
| 305 | if (!current_user.has_value()) { | 306 | if (!current_user.has_value()) { |
| 306 | return ""; | 307 | return ""; |
| 307 | } | 308 | } |
| 308 | 309 | ||
| 309 | if (!profile_manager->GetProfileBase(*current_user, profile)) { | 310 | if (!system.GetProfileManager().GetProfileBase(*current_user, profile)) { |
| 310 | return ""; | 311 | return ""; |
| 311 | } | 312 | } |
| 312 | 313 | ||
diff --git a/src/yuzu/multiplayer/lobby.h b/src/yuzu/multiplayer/lobby.h index 2674ae7c3..e78c9cae3 100644 --- a/src/yuzu/multiplayer/lobby.h +++ b/src/yuzu/multiplayer/lobby.h | |||
| @@ -24,10 +24,6 @@ namespace Core { | |||
| 24 | class System; | 24 | class System; |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | namespace Service::Account { | ||
| 28 | class ProfileManager; | ||
| 29 | } | ||
| 30 | |||
| 31 | /** | 27 | /** |
| 32 | * Listing of all public games pulled from services. The lobby should be simple enough for users to | 28 | * Listing of all public games pulled from services. The lobby should be simple enough for users to |
| 33 | * find the game they want to play, and join it. | 29 | * find the game they want to play, and join it. |
| @@ -103,7 +99,6 @@ private: | |||
| 103 | 99 | ||
| 104 | QFutureWatcher<AnnounceMultiplayerRoom::RoomList> room_list_watcher; | 100 | QFutureWatcher<AnnounceMultiplayerRoom::RoomList> room_list_watcher; |
| 105 | std::weak_ptr<Core::AnnounceMultiplayerSession> announce_multiplayer_session; | 101 | std::weak_ptr<Core::AnnounceMultiplayerSession> announce_multiplayer_session; |
| 106 | std::unique_ptr<Service::Account::ProfileManager> profile_manager; | ||
| 107 | QFutureWatcher<void>* watcher; | 102 | QFutureWatcher<void>* watcher; |
| 108 | Validation validation; | 103 | Validation validation; |
| 109 | Core::System& system; | 104 | Core::System& system; |
diff --git a/src/yuzu/play_time_manager.cpp b/src/yuzu/play_time_manager.cpp index 155c36b7d..94c99274d 100644 --- a/src/yuzu/play_time_manager.cpp +++ b/src/yuzu/play_time_manager.cpp | |||
| @@ -20,8 +20,8 @@ struct PlayTimeElement { | |||
| 20 | PlayTime play_time; | 20 | PlayTime play_time; |
| 21 | }; | 21 | }; |
| 22 | 22 | ||
| 23 | std::optional<std::filesystem::path> GetCurrentUserPlayTimePath() { | 23 | std::optional<std::filesystem::path> GetCurrentUserPlayTimePath( |
| 24 | const Service::Account::ProfileManager manager; | 24 | const Service::Account::ProfileManager& manager) { |
| 25 | const auto uuid = manager.GetUser(static_cast<s32>(Settings::values.current_user)); | 25 | const auto uuid = manager.GetUser(static_cast<s32>(Settings::values.current_user)); |
| 26 | if (!uuid.has_value()) { | 26 | if (!uuid.has_value()) { |
| 27 | return std::nullopt; | 27 | return std::nullopt; |
| @@ -30,8 +30,9 @@ std::optional<std::filesystem::path> GetCurrentUserPlayTimePath() { | |||
| 30 | uuid->RawString().append(".bin"); | 30 | uuid->RawString().append(".bin"); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | [[nodiscard]] bool ReadPlayTimeFile(PlayTimeDatabase& out_play_time_db) { | 33 | [[nodiscard]] bool ReadPlayTimeFile(PlayTimeDatabase& out_play_time_db, |
| 34 | const auto filename = GetCurrentUserPlayTimePath(); | 34 | const Service::Account::ProfileManager& manager) { |
| 35 | const auto filename = GetCurrentUserPlayTimePath(manager); | ||
| 35 | 36 | ||
| 36 | if (!filename.has_value()) { | 37 | if (!filename.has_value()) { |
| 37 | LOG_ERROR(Frontend, "Failed to get current user path"); | 38 | LOG_ERROR(Frontend, "Failed to get current user path"); |
| @@ -66,8 +67,9 @@ std::optional<std::filesystem::path> GetCurrentUserPlayTimePath() { | |||
| 66 | return true; | 67 | return true; |
| 67 | } | 68 | } |
| 68 | 69 | ||
| 69 | [[nodiscard]] bool WritePlayTimeFile(const PlayTimeDatabase& play_time_db) { | 70 | [[nodiscard]] bool WritePlayTimeFile(const PlayTimeDatabase& play_time_db, |
| 70 | const auto filename = GetCurrentUserPlayTimePath(); | 71 | const Service::Account::ProfileManager& manager) { |
| 72 | const auto filename = GetCurrentUserPlayTimePath(manager); | ||
| 71 | 73 | ||
| 72 | if (!filename.has_value()) { | 74 | if (!filename.has_value()) { |
| 73 | LOG_ERROR(Frontend, "Failed to get current user path"); | 75 | LOG_ERROR(Frontend, "Failed to get current user path"); |
| @@ -96,8 +98,9 @@ std::optional<std::filesystem::path> GetCurrentUserPlayTimePath() { | |||
| 96 | 98 | ||
| 97 | } // namespace | 99 | } // namespace |
| 98 | 100 | ||
| 99 | PlayTimeManager::PlayTimeManager() { | 101 | PlayTimeManager::PlayTimeManager(Service::Account::ProfileManager& profile_manager) |
| 100 | if (!ReadPlayTimeFile(database)) { | 102 | : manager{profile_manager} { |
| 103 | if (!ReadPlayTimeFile(database, manager)) { | ||
| 101 | LOG_ERROR(Frontend, "Failed to read play time database! Resetting to default."); | 104 | LOG_ERROR(Frontend, "Failed to read play time database! Resetting to default."); |
| 102 | } | 105 | } |
| 103 | } | 106 | } |
| @@ -142,7 +145,7 @@ void PlayTimeManager::AutoTimestamp(std::stop_token stop_token) { | |||
| 142 | } | 145 | } |
| 143 | 146 | ||
| 144 | void PlayTimeManager::Save() { | 147 | void PlayTimeManager::Save() { |
| 145 | if (!WritePlayTimeFile(database)) { | 148 | if (!WritePlayTimeFile(database, manager)) { |
| 146 | LOG_ERROR(Frontend, "Failed to update play time database!"); | 149 | LOG_ERROR(Frontend, "Failed to update play time database!"); |
| 147 | } | 150 | } |
| 148 | } | 151 | } |
diff --git a/src/yuzu/play_time_manager.h b/src/yuzu/play_time_manager.h index 5f96f3447..1714b9131 100644 --- a/src/yuzu/play_time_manager.h +++ b/src/yuzu/play_time_manager.h | |||
| @@ -11,6 +11,10 @@ | |||
| 11 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "common/polyfill_thread.h" | 12 | #include "common/polyfill_thread.h" |
| 13 | 13 | ||
| 14 | namespace Service::Account { | ||
| 15 | class ProfileManager; | ||
| 16 | } | ||
| 17 | |||
| 14 | namespace PlayTime { | 18 | namespace PlayTime { |
| 15 | 19 | ||
| 16 | using ProgramId = u64; | 20 | using ProgramId = u64; |
| @@ -19,7 +23,7 @@ using PlayTimeDatabase = std::map<ProgramId, PlayTime>; | |||
| 19 | 23 | ||
| 20 | class PlayTimeManager { | 24 | class PlayTimeManager { |
| 21 | public: | 25 | public: |
| 22 | explicit PlayTimeManager(); | 26 | explicit PlayTimeManager(Service::Account::ProfileManager& profile_manager); |
| 23 | ~PlayTimeManager(); | 27 | ~PlayTimeManager(); |
| 24 | 28 | ||
| 25 | YUZU_NON_COPYABLE(PlayTimeManager); | 29 | YUZU_NON_COPYABLE(PlayTimeManager); |
| @@ -32,11 +36,13 @@ public: | |||
| 32 | void Stop(); | 36 | void Stop(); |
| 33 | 37 | ||
| 34 | private: | 38 | private: |
| 39 | void AutoTimestamp(std::stop_token stop_token); | ||
| 40 | void Save(); | ||
| 41 | |||
| 35 | PlayTimeDatabase database; | 42 | PlayTimeDatabase database; |
| 36 | u64 running_program_id; | 43 | u64 running_program_id; |
| 37 | std::jthread play_time_thread; | 44 | std::jthread play_time_thread; |
| 38 | void AutoTimestamp(std::stop_token stop_token); | 45 | Service::Account::ProfileManager& manager; |
| 39 | void Save(); | ||
| 40 | }; | 46 | }; |
| 41 | 47 | ||
| 42 | QString ReadablePlayTime(qulonglong time_seconds); | 48 | QString ReadablePlayTime(qulonglong time_seconds); |