summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/ring_buffer.h1
-rw-r--r--src/common/settings.h4
-rw-r--r--src/core/CMakeLists.txt9
-rw-r--r--src/core/core.cpp8
-rw-r--r--src/core/file_sys/fssystem/fssystem_aes_xts_storage.cpp4
-rw-r--r--src/core/hle/service/acc/acc.cpp23
-rw-r--r--src/core/hle/service/acc/acc_u1.cpp2
-rw-r--r--src/core/hle/service/am/am_types.h5
-rw-r--r--src/core/hle/service/am/service/common_state_getter.cpp4
-rw-r--r--src/core/hle/service/am/service/common_state_getter.h3
-rw-r--r--src/core/hle/service/aoc/addon_content_manager.cpp223
-rw-r--r--src/core/hle/service/aoc/addon_content_manager.h51
-rw-r--r--src/core/hle/service/aoc/aoc_u.cpp340
-rw-r--r--src/core/hle/service/aoc/aoc_u.h45
-rw-r--r--src/core/hle/service/aoc/purchase_event_manager.cpp67
-rw-r--r--src/core/hle/service/aoc/purchase_event_manager.h30
-rw-r--r--src/core/hle/service/audio/audio_controller.cpp2
-rw-r--r--src/core/hle/service/btdrv/btdrv.cpp32
-rw-r--r--src/core/hle/service/erpt/erpt.cpp40
-rw-r--r--src/core/hle/service/filesystem/fsp/fsp_srv.cpp72
-rw-r--r--src/core/hle/service/filesystem/fsp/fsp_srv.h16
-rw-r--r--src/core/hle/service/friend/friend.cpp91
-rw-r--r--src/core/hle/service/glue/time/manager.cpp7
-rw-r--r--src/core/hle/service/glue/time/worker.cpp7
-rw-r--r--src/core/hle/service/hid/hid_system_server.cpp12
-rw-r--r--src/core/hle/service/hid/hid_system_server.h1
-rw-r--r--src/core/hle/service/lbl/lbl.cpp31
-rw-r--r--src/core/hle/service/ldn/monitor_service.cpp13
-rw-r--r--src/core/hle/service/ldn/monitor_service.h1
-rw-r--r--src/core/hle/service/nfc/common/device_manager.cpp8
-rw-r--r--src/core/hle/service/nfc/common/device_manager.h5
-rw-r--r--src/core/hle/service/nfc/nfc.cpp4
-rw-r--r--src/core/hle/service/nfc/nfc_interface.cpp24
-rw-r--r--src/core/hle/service/nfc/nfc_interface.h6
-rw-r--r--src/core/hle/service/npns/npns.cpp42
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp21
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_gpu.h3
-rw-r--r--src/core/hle/service/server_manager.cpp14
-rw-r--r--src/core/hle/service/services.cpp2
-rw-r--r--src/core/hle/service/set/setting_formats/system_settings.cpp4
-rw-r--r--src/core/hle/service/set/settings_types.h8
-rw-r--r--src/core/hle/service/set/system_settings_server.cpp43
-rw-r--r--src/core/hle/service/set/system_settings_server.h23
-rw-r--r--src/core/hle/service/ssl/cert_store.cpp156
-rw-r--r--src/core/hle/service/ssl/cert_store.h42
-rw-r--r--src/core/hle/service/ssl/ssl.cpp25
-rw-r--r--src/core/hle/service/ssl/ssl_types.h107
-rw-r--r--src/hid_core/frontend/emulated_controller.cpp22
-rw-r--r--src/hid_core/frontend/emulated_controller.h1
-rw-r--r--src/hid_core/hid_types.h6
-rw-r--r--src/hid_core/resources/npad/npad.cpp1
-rw-r--r--src/input_common/drivers/android.cpp41
-rw-r--r--src/input_common/drivers/android.h10
-rw-r--r--src/input_common/drivers/sdl_driver.h5
-rw-r--r--src/input_common/input_engine.h5
-rw-r--r--src/video_core/buffer_cache/buffer_cache.h5
-rw-r--r--src/video_core/buffer_cache/usage_tracker.h6
-rw-r--r--src/video_core/control/channel_state.cpp3
-rw-r--r--src/video_core/control/channel_state.h3
-rw-r--r--src/video_core/control/channel_state_cache.cpp2
-rw-r--r--src/video_core/control/channel_state_cache.h8
-rw-r--r--src/video_core/control/channel_state_cache.inc2
-rw-r--r--src/video_core/engines/draw_manager.cpp11
-rw-r--r--src/video_core/gpu.cpp8
-rw-r--r--src/video_core/gpu.h2
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp29
-rw-r--r--src/video_core/renderer_opengl/gl_shader_cache.cpp1
-rw-r--r--src/video_core/renderer_vulkan/vk_query_cache.cpp14
-rw-r--r--src/video_core/renderer_vulkan/vk_rasterizer.cpp85
-rw-r--r--src/video_core/renderer_vulkan/vk_texture_cache.cpp7
-rw-r--r--src/video_core/renderer_vulkan/vk_texture_cache.h5
-rw-r--r--src/video_core/texture_cache/texture_cache.h38
-rw-r--r--src/yuzu/configuration/configure_applets.cpp2
-rwxr-xr-xtools/reset-submodules.sh8
74 files changed, 1358 insertions, 653 deletions
diff --git a/src/common/ring_buffer.h b/src/common/ring_buffer.h
index e7e9fdb38..b92db6185 100644
--- a/src/common/ring_buffer.h
+++ b/src/common/ring_buffer.h
@@ -8,6 +8,7 @@
8#include <atomic> 8#include <atomic>
9#include <cstddef> 9#include <cstddef>
10#include <cstring> 10#include <cstring>
11#include <limits>
11#include <new> 12#include <new>
12#include <span> 13#include <span>
13#include <type_traits> 14#include <type_traits>
diff --git a/src/common/settings.h b/src/common/settings.h
index b2b071e7e..61969af2b 100644
--- a/src/common/settings.h
+++ b/src/common/settings.h
@@ -140,7 +140,7 @@ struct Values {
140 Category::LibraryApplet}; 140 Category::LibraryApplet};
141 Setting<AppletMode> data_erase_applet_mode{linkage, AppletMode::HLE, "data_erase_applet_mode", 141 Setting<AppletMode> data_erase_applet_mode{linkage, AppletMode::HLE, "data_erase_applet_mode",
142 Category::LibraryApplet}; 142 Category::LibraryApplet};
143 Setting<AppletMode> error_applet_mode{linkage, AppletMode::HLE, "error_applet_mode", 143 Setting<AppletMode> error_applet_mode{linkage, AppletMode::LLE, "error_applet_mode",
144 Category::LibraryApplet}; 144 Category::LibraryApplet};
145 Setting<AppletMode> net_connect_applet_mode{linkage, AppletMode::HLE, "net_connect_applet_mode", 145 Setting<AppletMode> net_connect_applet_mode{linkage, AppletMode::HLE, "net_connect_applet_mode",
146 Category::LibraryApplet}; 146 Category::LibraryApplet};
@@ -435,8 +435,6 @@ struct Values {
435 linkage, false, "disable_shader_loop_safety_checks", Category::RendererDebug}; 435 linkage, false, "disable_shader_loop_safety_checks", Category::RendererDebug};
436 Setting<bool> enable_renderdoc_hotkey{linkage, false, "renderdoc_hotkey", 436 Setting<bool> enable_renderdoc_hotkey{linkage, false, "renderdoc_hotkey",
437 Category::RendererDebug}; 437 Category::RendererDebug};
438 // TODO: remove this once AMDVLK supports VK_EXT_depth_bias_control
439 bool renderer_amdvlk_depth_bias_workaround{};
440 Setting<bool> disable_buffer_reorder{linkage, false, "disable_buffer_reorder", 438 Setting<bool> disable_buffer_reorder{linkage, false, "disable_buffer_reorder",
441 Category::RendererDebug}; 439 Category::RendererDebug};
442 440
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 93e403b26..de158eea7 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -486,8 +486,10 @@ add_library(core STATIC
486 hle/service/am/service/system_applet_proxy.h 486 hle/service/am/service/system_applet_proxy.h
487 hle/service/am/service/window_controller.cpp 487 hle/service/am/service/window_controller.cpp
488 hle/service/am/service/window_controller.h 488 hle/service/am/service/window_controller.h
489 hle/service/aoc/aoc_u.cpp 489 hle/service/aoc/addon_content_manager.cpp
490 hle/service/aoc/aoc_u.h 490 hle/service/aoc/addon_content_manager.h
491 hle/service/aoc/purchase_event_manager.cpp
492 hle/service/aoc/purchase_event_manager.h
491 hle/service/apm/apm.cpp 493 hle/service/apm/apm.cpp
492 hle/service/apm/apm.h 494 hle/service/apm/apm.h
493 hle/service/apm/apm_controller.cpp 495 hle/service/apm/apm_controller.cpp
@@ -1049,9 +1051,12 @@ add_library(core STATIC
1049 hle/service/spl/spl_module.h 1051 hle/service/spl/spl_module.h
1050 hle/service/spl/spl_results.h 1052 hle/service/spl/spl_results.h
1051 hle/service/spl/spl_types.h 1053 hle/service/spl/spl_types.h
1054 hle/service/ssl/cert_store.cpp
1055 hle/service/ssl/cert_store.h
1052 hle/service/ssl/ssl.cpp 1056 hle/service/ssl/ssl.cpp
1053 hle/service/ssl/ssl.h 1057 hle/service/ssl/ssl.h
1054 hle/service/ssl/ssl_backend.h 1058 hle/service/ssl/ssl_backend.h
1059 hle/service/ssl/ssl_types.h
1055 hle/service/usb/usb.cpp 1060 hle/service/usb/usb.cpp
1056 hle/service/usb/usb.h 1061 hle/service/usb/usb.h
1057 hle/service/vi/application_display_service.cpp 1062 hle/service/vi/application_display_service.cpp
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 9e8936728..dc515bc82 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -425,11 +425,6 @@ struct System::Impl {
425 room_member->SendGameInfo(game_info); 425 room_member->SendGameInfo(game_info);
426 } 426 }
427 427
428 // Workarounds:
429 // Activate this in Super Smash Brothers Ultimate, it only affects AMD cards using AMDVLK
430 Settings::values.renderer_amdvlk_depth_bias_workaround =
431 params.program_id == 0x1006A800016E000ULL;
432
433 status = SystemResultStatus::Success; 428 status = SystemResultStatus::Success;
434 return status; 429 return status;
435 } 430 }
@@ -489,9 +484,6 @@ struct System::Impl {
489 room_member->SendGameInfo(game_info); 484 room_member->SendGameInfo(game_info);
490 } 485 }
491 486
492 // Workarounds
493 Settings::values.renderer_amdvlk_depth_bias_workaround = false;
494
495 LOG_DEBUG(Core, "Shutdown OK"); 487 LOG_DEBUG(Core, "Shutdown OK");
496 } 488 }
497 489
diff --git a/src/core/file_sys/fssystem/fssystem_aes_xts_storage.cpp b/src/core/file_sys/fssystem/fssystem_aes_xts_storage.cpp
index 022424229..efc5aa0b1 100644
--- a/src/core/file_sys/fssystem/fssystem_aes_xts_storage.cpp
+++ b/src/core/file_sys/fssystem/fssystem_aes_xts_storage.cpp
@@ -31,8 +31,8 @@ AesXtsStorage::AesXtsStorage(VirtualFile base, const void* key1, const void* key
31 ASSERT(iv_size == IvSize); 31 ASSERT(iv_size == IvSize);
32 ASSERT(Common::IsAligned(m_block_size, AesBlockSize)); 32 ASSERT(Common::IsAligned(m_block_size, AesBlockSize));
33 33
34 std::memcpy(m_key.data() + 0, key1, KeySize); 34 std::memcpy(m_key.data() + 0, key1, KeySize / 2);
35 std::memcpy(m_key.data() + 0x10, key2, KeySize); 35 std::memcpy(m_key.data() + 0x10, key2, KeySize / 2);
36 std::memcpy(m_iv.data(), iv, IvSize); 36 std::memcpy(m_iv.data(), iv, IvSize);
37 37
38 m_cipher.emplace(m_key, Core::Crypto::Mode::XTS); 38 m_cipher.emplace(m_key, Core::Crypto::Mode::XTS);
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp
index f21553644..fad111d44 100644
--- a/src/core/hle/service/acc/acc.cpp
+++ b/src/core/hle/service/acc/acc.cpp
@@ -25,8 +25,8 @@
25#include "core/hle/service/acc/async_context.h" 25#include "core/hle/service/acc/async_context.h"
26#include "core/hle/service/acc/errors.h" 26#include "core/hle/service/acc/errors.h"
27#include "core/hle/service/acc/profile_manager.h" 27#include "core/hle/service/acc/profile_manager.h"
28#include "core/hle/service/cmif_serialization.h"
28#include "core/hle/service/glue/glue_manager.h" 29#include "core/hle/service/glue/glue_manager.h"
29#include "core/hle/service/ipc_helpers.h"
30#include "core/hle/service/server_manager.h" 30#include "core/hle/service/server_manager.h"
31#include "core/loader/loader.h" 31#include "core/loader/loader.h"
32 32
@@ -74,12 +74,12 @@ static void SanitizeJPEGImageSize(std::vector<u8>& image) {
74 74
75class IManagerForSystemService final : public ServiceFramework<IManagerForSystemService> { 75class IManagerForSystemService final : public ServiceFramework<IManagerForSystemService> {
76public: 76public:
77 explicit IManagerForSystemService(Core::System& system_, Common::UUID) 77 explicit IManagerForSystemService(Core::System& system_, Common::UUID uuid)
78 : ServiceFramework{system_, "IManagerForSystemService"} { 78 : ServiceFramework{system_, "IManagerForSystemService"}, account_id{uuid} {
79 // clang-format off 79 // clang-format off
80 static const FunctionInfo functions[] = { 80 static const FunctionInfo functions[] = {
81 {0, &IManagerForSystemService::CheckAvailability, "CheckAvailability"}, 81 {0, D<&IManagerForSystemService::CheckAvailability>, "CheckAvailability"},
82 {1, nullptr, "GetAccountId"}, 82 {1, D<&IManagerForSystemService::GetAccountId>, "GetAccountId"},
83 {2, nullptr, "EnsureIdTokenCacheAsync"}, 83 {2, nullptr, "EnsureIdTokenCacheAsync"},
84 {3, nullptr, "LoadIdTokenCache"}, 84 {3, nullptr, "LoadIdTokenCache"},
85 {100, nullptr, "SetSystemProgramIdentification"}, 85 {100, nullptr, "SetSystemProgramIdentification"},
@@ -109,11 +109,18 @@ public:
109 } 109 }
110 110
111private: 111private:
112 void CheckAvailability(HLERequestContext& ctx) { 112 Result CheckAvailability() {
113 LOG_WARNING(Service_ACC, "(STUBBED) called"); 113 LOG_WARNING(Service_ACC, "(STUBBED) called");
114 IPC::ResponseBuilder rb{ctx, 2}; 114 R_SUCCEED();
115 rb.Push(ResultSuccess);
116 } 115 }
116
117 Result GetAccountId(Out<u64> out_account_id) {
118 LOG_WARNING(Service_ACC, "(STUBBED) called");
119 *out_account_id = account_id.Hash();
120 R_SUCCEED();
121 }
122
123 Common::UUID account_id;
117}; 124};
118 125
119// 3.0.0+ 126// 3.0.0+
diff --git a/src/core/hle/service/acc/acc_u1.cpp b/src/core/hle/service/acc/acc_u1.cpp
index 92f704c2f..eecc94387 100644
--- a/src/core/hle/service/acc/acc_u1.cpp
+++ b/src/core/hle/service/acc/acc_u1.cpp
@@ -23,7 +23,7 @@ ACC_U1::ACC_U1(std::shared_ptr<Module> module_, std::shared_ptr<ProfileManager>
23 {99, nullptr, "DebugActivateOpenContextRetention"}, 23 {99, nullptr, "DebugActivateOpenContextRetention"},
24 {100, nullptr, "GetUserRegistrationNotifier"}, 24 {100, nullptr, "GetUserRegistrationNotifier"},
25 {101, nullptr, "GetUserStateChangeNotifier"}, 25 {101, nullptr, "GetUserStateChangeNotifier"},
26 {102, nullptr, "GetBaasAccountManagerForSystemService"}, 26 {102, &ACC_U1::GetBaasAccountManagerForSystemService, "GetBaasAccountManagerForSystemService"},
27 {103, nullptr, "GetBaasUserAvailabilityChangeNotifier"}, 27 {103, nullptr, "GetBaasUserAvailabilityChangeNotifier"},
28 {104, nullptr, "GetProfileUpdateNotifier"}, 28 {104, nullptr, "GetProfileUpdateNotifier"},
29 {105, nullptr, "CheckNetworkServiceAvailabilityAsync"}, 29 {105, nullptr, "CheckNetworkServiceAvailabilityAsync"},
diff --git a/src/core/hle/service/am/am_types.h b/src/core/hle/service/am/am_types.h
index 46afb3996..a14defb40 100644
--- a/src/core/hle/service/am/am_types.h
+++ b/src/core/hle/service/am/am_types.h
@@ -48,11 +48,6 @@ enum class SystemButtonType {
48 CaptureButtonLongPressing, 48 CaptureButtonLongPressing,
49}; 49};
50 50
51enum class SysPlatformRegion : s32 {
52 Global = 1,
53 Terra = 2,
54};
55
56struct AppletProcessLaunchReason { 51struct AppletProcessLaunchReason {
57 u8 flag; 52 u8 flag;
58 INSERT_PADDING_BYTES(3); 53 INSERT_PADDING_BYTES(3);
diff --git a/src/core/hle/service/am/service/common_state_getter.cpp b/src/core/hle/service/am/service/common_state_getter.cpp
index 548498e83..a32855ffa 100644
--- a/src/core/hle/service/am/service/common_state_getter.cpp
+++ b/src/core/hle/service/am/service/common_state_getter.cpp
@@ -260,9 +260,9 @@ Result ICommonStateGetter::GetAppletLaunchedHistory(
260} 260}
261 261
262Result ICommonStateGetter::GetSettingsPlatformRegion( 262Result ICommonStateGetter::GetSettingsPlatformRegion(
263 Out<SysPlatformRegion> out_settings_platform_region) { 263 Out<Set::PlatformRegion> out_settings_platform_region) {
264 LOG_INFO(Service_AM, "called"); 264 LOG_INFO(Service_AM, "called");
265 *out_settings_platform_region = SysPlatformRegion::Global; 265 *out_settings_platform_region = Set::PlatformRegion::Global;
266 R_SUCCEED(); 266 R_SUCCEED();
267} 267}
268 268
diff --git a/src/core/hle/service/am/service/common_state_getter.h b/src/core/hle/service/am/service/common_state_getter.h
index 5a8dca3d6..59a46fa94 100644
--- a/src/core/hle/service/am/service/common_state_getter.h
+++ b/src/core/hle/service/am/service/common_state_getter.h
@@ -8,6 +8,7 @@
8#include "core/hle/service/cmif_types.h" 8#include "core/hle/service/cmif_types.h"
9#include "core/hle/service/pm/pm.h" 9#include "core/hle/service/pm/pm.h"
10#include "core/hle/service/service.h" 10#include "core/hle/service/service.h"
11#include "core/hle/service/set/settings_types.h"
11 12
12namespace Kernel { 13namespace Kernel {
13class KReadableEvent; 14class KReadableEvent;
@@ -50,7 +51,7 @@ private:
50 Result GetOperationModeSystemInfo(Out<u32> out_operation_mode_system_info); 51 Result GetOperationModeSystemInfo(Out<u32> out_operation_mode_system_info);
51 Result GetAppletLaunchedHistory(Out<s32> out_count, 52 Result GetAppletLaunchedHistory(Out<s32> out_count,
52 OutArray<AppletId, BufferAttr_HipcMapAlias> out_applet_ids); 53 OutArray<AppletId, BufferAttr_HipcMapAlias> out_applet_ids);
53 Result GetSettingsPlatformRegion(Out<SysPlatformRegion> out_settings_platform_region); 54 Result GetSettingsPlatformRegion(Out<Set::PlatformRegion> out_settings_platform_region);
54 Result SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled(); 55 Result SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled();
55 56
56 void SetCpuBoostMode(HLERequestContext& ctx); 57 void SetCpuBoostMode(HLERequestContext& ctx);
diff --git a/src/core/hle/service/aoc/addon_content_manager.cpp b/src/core/hle/service/aoc/addon_content_manager.cpp
new file mode 100644
index 000000000..d47f57d64
--- /dev/null
+++ b/src/core/hle/service/aoc/addon_content_manager.cpp
@@ -0,0 +1,223 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include <algorithm>
5#include <numeric>
6#include <vector>
7
8#include "common/logging/log.h"
9#include "common/settings.h"
10#include "core/core.h"
11#include "core/file_sys/common_funcs.h"
12#include "core/file_sys/content_archive.h"
13#include "core/file_sys/control_metadata.h"
14#include "core/file_sys/nca_metadata.h"
15#include "core/file_sys/patch_manager.h"
16#include "core/file_sys/registered_cache.h"
17#include "core/hle/kernel/k_event.h"
18#include "core/hle/service/aoc/addon_content_manager.h"
19#include "core/hle/service/aoc/purchase_event_manager.h"
20#include "core/hle/service/cmif_serialization.h"
21#include "core/hle/service/ipc_helpers.h"
22#include "core/hle/service/server_manager.h"
23#include "core/loader/loader.h"
24
25namespace Service::AOC {
26
27static bool CheckAOCTitleIDMatchesBase(u64 title_id, u64 base) {
28 return FileSys::GetBaseTitleID(title_id) == base;
29}
30
31static std::vector<u64> AccumulateAOCTitleIDs(Core::System& system) {
32 std::vector<u64> add_on_content;
33 const auto& rcu = system.GetContentProvider();
34 const auto list =
35 rcu.ListEntriesFilter(FileSys::TitleType::AOC, FileSys::ContentRecordType::Data);
36 std::transform(list.begin(), list.end(), std::back_inserter(add_on_content),
37 [](const FileSys::ContentProviderEntry& rce) { return rce.title_id; });
38 add_on_content.erase(
39 std::remove_if(
40 add_on_content.begin(), add_on_content.end(),
41 [&rcu](u64 tid) {
42 return rcu.GetEntry(tid, FileSys::ContentRecordType::Data)->GetStatus() !=
43 Loader::ResultStatus::Success;
44 }),
45 add_on_content.end());
46 return add_on_content;
47}
48
49IAddOnContentManager::IAddOnContentManager(Core::System& system_)
50 : ServiceFramework{system_, "aoc:u"}, add_on_content{AccumulateAOCTitleIDs(system)},
51 service_context{system_, "aoc:u"} {
52 // clang-format off
53 static const FunctionInfo functions[] = {
54 {0, nullptr, "CountAddOnContentByApplicationId"},
55 {1, nullptr, "ListAddOnContentByApplicationId"},
56 {2, D<&IAddOnContentManager::CountAddOnContent>, "CountAddOnContent"},
57 {3, D<&IAddOnContentManager::ListAddOnContent>, "ListAddOnContent"},
58 {4, nullptr, "GetAddOnContentBaseIdByApplicationId"},
59 {5, D<&IAddOnContentManager::GetAddOnContentBaseId>, "GetAddOnContentBaseId"},
60 {6, nullptr, "PrepareAddOnContentByApplicationId"},
61 {7, D<&IAddOnContentManager::PrepareAddOnContent>, "PrepareAddOnContent"},
62 {8, D<&IAddOnContentManager::GetAddOnContentListChangedEvent>, "GetAddOnContentListChangedEvent"},
63 {9, nullptr, "GetAddOnContentLostErrorCode"},
64 {10, D<&IAddOnContentManager::GetAddOnContentListChangedEventWithProcessId>, "GetAddOnContentListChangedEventWithProcessId"},
65 {11, D<&IAddOnContentManager::NotifyMountAddOnContent>, "NotifyMountAddOnContent"},
66 {12, D<&IAddOnContentManager::NotifyUnmountAddOnContent>, "NotifyUnmountAddOnContent"},
67 {13, nullptr, "IsAddOnContentMountedForDebug"},
68 {50, D<&IAddOnContentManager::CheckAddOnContentMountStatus>, "CheckAddOnContentMountStatus"},
69 {100, D<&IAddOnContentManager::CreateEcPurchasedEventManager>, "CreateEcPurchasedEventManager"},
70 {101, D<&IAddOnContentManager::CreatePermanentEcPurchasedEventManager>, "CreatePermanentEcPurchasedEventManager"},
71 {110, nullptr, "CreateContentsServiceManager"},
72 {200, nullptr, "SetRequiredAddOnContentsOnContentsAvailabilityTransition"},
73 {300, nullptr, "SetupHostAddOnContent"},
74 {301, nullptr, "GetRegisteredAddOnContentPath"},
75 {302, nullptr, "UpdateCachedList"},
76 };
77 // clang-format on
78
79 RegisterHandlers(functions);
80
81 aoc_change_event = service_context.CreateEvent("GetAddOnContentListChanged:Event");
82}
83
84IAddOnContentManager::~IAddOnContentManager() {
85 service_context.CloseEvent(aoc_change_event);
86}
87
88Result IAddOnContentManager::CountAddOnContent(Out<u32> out_count, ClientProcessId process_id) {
89 LOG_DEBUG(Service_AOC, "called. process_id={}", process_id.pid);
90
91 const auto current = system.GetApplicationProcessProgramID();
92
93 const auto& disabled = Settings::values.disabled_addons[current];
94 if (std::find(disabled.begin(), disabled.end(), "DLC") != disabled.end()) {
95 *out_count = 0;
96 R_SUCCEED();
97 }
98
99 *out_count = static_cast<u32>(
100 std::count_if(add_on_content.begin(), add_on_content.end(),
101 [current](u64 tid) { return CheckAOCTitleIDMatchesBase(tid, current); }));
102
103 R_SUCCEED();
104}
105
106Result IAddOnContentManager::ListAddOnContent(Out<u32> out_count,
107 OutBuffer<BufferAttr_HipcMapAlias> out_addons,
108 u32 offset, u32 count, ClientProcessId process_id) {
109 LOG_DEBUG(Service_AOC, "called with offset={}, count={}, process_id={}", offset, count,
110 process_id.pid);
111
112 const auto current = FileSys::GetBaseTitleID(system.GetApplicationProcessProgramID());
113
114 std::vector<u32> out;
115 const auto& disabled = Settings::values.disabled_addons[current];
116 if (std::find(disabled.begin(), disabled.end(), "DLC") == disabled.end()) {
117 for (u64 content_id : add_on_content) {
118 if (FileSys::GetBaseTitleID(content_id) != current) {
119 continue;
120 }
121
122 out.push_back(static_cast<u32>(FileSys::GetAOCID(content_id)));
123 }
124 }
125
126 // TODO(DarkLordZach): Find the correct error code.
127 R_UNLESS(out.size() >= offset, ResultUnknown);
128
129 *out_count = static_cast<u32>(std::min<size_t>(out.size() - offset, count));
130 std::rotate(out.begin(), out.begin() + offset, out.end());
131
132 std::memcpy(out_addons.data(), out.data(), *out_count * sizeof(u32));
133
134 R_SUCCEED();
135}
136
137Result IAddOnContentManager::GetAddOnContentBaseId(Out<u64> out_title_id,
138 ClientProcessId process_id) {
139 LOG_DEBUG(Service_AOC, "called. process_id={}", process_id.pid);
140
141 const auto title_id = system.GetApplicationProcessProgramID();
142 const FileSys::PatchManager pm{title_id, system.GetFileSystemController(),
143 system.GetContentProvider()};
144
145 const auto res = pm.GetControlMetadata();
146 if (res.first == nullptr) {
147 *out_title_id = FileSys::GetAOCBaseTitleID(title_id);
148 R_SUCCEED();
149 }
150
151 *out_title_id = res.first->GetDLCBaseTitleId();
152
153 R_SUCCEED();
154}
155
156Result IAddOnContentManager::PrepareAddOnContent(s32 addon_index, ClientProcessId process_id) {
157 LOG_WARNING(Service_AOC, "(STUBBED) called with addon_index={}, process_id={}", addon_index,
158 process_id.pid);
159
160 R_SUCCEED();
161}
162
163Result IAddOnContentManager::GetAddOnContentListChangedEvent(
164 OutCopyHandle<Kernel::KReadableEvent> out_event) {
165 LOG_WARNING(Service_AOC, "(STUBBED) called");
166
167 *out_event = &aoc_change_event->GetReadableEvent();
168
169 R_SUCCEED();
170}
171
172Result IAddOnContentManager::GetAddOnContentListChangedEventWithProcessId(
173 OutCopyHandle<Kernel::KReadableEvent> out_event, ClientProcessId process_id) {
174 LOG_WARNING(Service_AOC, "(STUBBED) called");
175
176 *out_event = &aoc_change_event->GetReadableEvent();
177
178 R_SUCCEED();
179}
180
181Result IAddOnContentManager::NotifyMountAddOnContent() {
182 LOG_WARNING(Service_AOC, "(STUBBED) called");
183
184 R_SUCCEED();
185}
186
187Result IAddOnContentManager::NotifyUnmountAddOnContent() {
188 LOG_WARNING(Service_AOC, "(STUBBED) called");
189
190 R_SUCCEED();
191}
192
193Result IAddOnContentManager::CheckAddOnContentMountStatus() {
194 LOG_WARNING(Service_AOC, "(STUBBED) called");
195
196 R_SUCCEED();
197}
198
199Result IAddOnContentManager::CreateEcPurchasedEventManager(
200 OutInterface<IPurchaseEventManager> out_interface) {
201 LOG_WARNING(Service_AOC, "(STUBBED) called");
202
203 *out_interface = std::make_shared<IPurchaseEventManager>(system);
204
205 R_SUCCEED();
206}
207
208Result IAddOnContentManager::CreatePermanentEcPurchasedEventManager(
209 OutInterface<IPurchaseEventManager> out_interface) {
210 LOG_WARNING(Service_AOC, "(STUBBED) called");
211
212 *out_interface = std::make_shared<IPurchaseEventManager>(system);
213
214 R_SUCCEED();
215}
216
217void LoopProcess(Core::System& system) {
218 auto server_manager = std::make_unique<ServerManager>(system);
219 server_manager->RegisterNamedService("aoc:u", std::make_shared<IAddOnContentManager>(system));
220 ServerManager::RunServer(std::move(server_manager));
221}
222
223} // namespace Service::AOC
diff --git a/src/core/hle/service/aoc/addon_content_manager.h b/src/core/hle/service/aoc/addon_content_manager.h
new file mode 100644
index 000000000..91857df4c
--- /dev/null
+++ b/src/core/hle/service/aoc/addon_content_manager.h
@@ -0,0 +1,51 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include "core/hle/service/cmif_types.h"
7#include "core/hle/service/kernel_helpers.h"
8#include "core/hle/service/service.h"
9
10namespace Core {
11class System;
12}
13
14namespace Kernel {
15class KEvent;
16}
17
18namespace Service::AOC {
19
20class IPurchaseEventManager;
21
22class IAddOnContentManager final : public ServiceFramework<IAddOnContentManager> {
23public:
24 explicit IAddOnContentManager(Core::System& system);
25 ~IAddOnContentManager() override;
26
27 Result CountAddOnContent(Out<u32> out_count, ClientProcessId process_id);
28 Result ListAddOnContent(Out<u32> out_count, OutBuffer<BufferAttr_HipcMapAlias> out_addons,
29 u32 offset, u32 count, ClientProcessId process_id);
30 Result GetAddOnContentBaseId(Out<u64> out_title_id, ClientProcessId process_id);
31 Result PrepareAddOnContent(s32 addon_index, ClientProcessId process_id);
32 Result GetAddOnContentListChangedEvent(OutCopyHandle<Kernel::KReadableEvent> out_event);
33 Result GetAddOnContentListChangedEventWithProcessId(
34 OutCopyHandle<Kernel::KReadableEvent> out_event, ClientProcessId process_id);
35 Result NotifyMountAddOnContent();
36 Result NotifyUnmountAddOnContent();
37 Result CheckAddOnContentMountStatus();
38 Result CreateEcPurchasedEventManager(OutInterface<IPurchaseEventManager> out_interface);
39 Result CreatePermanentEcPurchasedEventManager(
40 OutInterface<IPurchaseEventManager> out_interface);
41
42private:
43 std::vector<u64> add_on_content;
44 KernelHelpers::ServiceContext service_context;
45
46 Kernel::KEvent* aoc_change_event;
47};
48
49void LoopProcess(Core::System& system);
50
51} // namespace Service::AOC
diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp
deleted file mode 100644
index 486719cc0..000000000
--- a/src/core/hle/service/aoc/aoc_u.cpp
+++ /dev/null
@@ -1,340 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include <algorithm>
5#include <numeric>
6#include <vector>
7
8#include "common/logging/log.h"
9#include "common/settings.h"
10#include "core/core.h"
11#include "core/file_sys/common_funcs.h"
12#include "core/file_sys/content_archive.h"
13#include "core/file_sys/control_metadata.h"
14#include "core/file_sys/nca_metadata.h"
15#include "core/file_sys/patch_manager.h"
16#include "core/file_sys/registered_cache.h"
17#include "core/hle/kernel/k_event.h"
18#include "core/hle/service/aoc/aoc_u.h"
19#include "core/hle/service/ipc_helpers.h"
20#include "core/hle/service/server_manager.h"
21#include "core/loader/loader.h"
22
23namespace Service::AOC {
24
25constexpr Result ResultNoPurchasedProductInfoAvailable{ErrorModule::NIMShop, 400};
26
27static bool CheckAOCTitleIDMatchesBase(u64 title_id, u64 base) {
28 return FileSys::GetBaseTitleID(title_id) == base;
29}
30
31static std::vector<u64> AccumulateAOCTitleIDs(Core::System& system) {
32 std::vector<u64> add_on_content;
33 const auto& rcu = system.GetContentProvider();
34 const auto list =
35 rcu.ListEntriesFilter(FileSys::TitleType::AOC, FileSys::ContentRecordType::Data);
36 std::transform(list.begin(), list.end(), std::back_inserter(add_on_content),
37 [](const FileSys::ContentProviderEntry& rce) { return rce.title_id; });
38 add_on_content.erase(
39 std::remove_if(
40 add_on_content.begin(), add_on_content.end(),
41 [&rcu](u64 tid) {
42 return rcu.GetEntry(tid, FileSys::ContentRecordType::Data)->GetStatus() !=
43 Loader::ResultStatus::Success;
44 }),
45 add_on_content.end());
46 return add_on_content;
47}
48
49class IPurchaseEventManager final : public ServiceFramework<IPurchaseEventManager> {
50public:
51 explicit IPurchaseEventManager(Core::System& system_)
52 : ServiceFramework{system_, "IPurchaseEventManager"}, service_context{
53 system, "IPurchaseEventManager"} {
54 // clang-format off
55 static const FunctionInfo functions[] = {
56 {0, &IPurchaseEventManager::SetDefaultDeliveryTarget, "SetDefaultDeliveryTarget"},
57 {1, &IPurchaseEventManager::SetDeliveryTarget, "SetDeliveryTarget"},
58 {2, &IPurchaseEventManager::GetPurchasedEventReadableHandle, "GetPurchasedEventReadableHandle"},
59 {3, &IPurchaseEventManager::PopPurchasedProductInfo, "PopPurchasedProductInfo"},
60 {4, &IPurchaseEventManager::PopPurchasedProductInfoWithUid, "PopPurchasedProductInfoWithUid"},
61 };
62 // clang-format on
63
64 RegisterHandlers(functions);
65
66 purchased_event = service_context.CreateEvent("IPurchaseEventManager:PurchasedEvent");
67 }
68
69 ~IPurchaseEventManager() override {
70 service_context.CloseEvent(purchased_event);
71 }
72
73private:
74 void SetDefaultDeliveryTarget(HLERequestContext& ctx) {
75 IPC::RequestParser rp{ctx};
76
77 const auto unknown_1 = rp.Pop<u64>();
78 [[maybe_unused]] const auto unknown_2 = ctx.ReadBuffer();
79
80 LOG_WARNING(Service_AOC, "(STUBBED) called, unknown_1={}", unknown_1);
81
82 IPC::ResponseBuilder rb{ctx, 2};
83 rb.Push(ResultSuccess);
84 }
85
86 void SetDeliveryTarget(HLERequestContext& ctx) {
87 IPC::RequestParser rp{ctx};
88
89 const auto unknown_1 = rp.Pop<u64>();
90 [[maybe_unused]] const auto unknown_2 = ctx.ReadBuffer();
91
92 LOG_WARNING(Service_AOC, "(STUBBED) called, unknown_1={}", unknown_1);
93
94 IPC::ResponseBuilder rb{ctx, 2};
95 rb.Push(ResultSuccess);
96 }
97
98 void GetPurchasedEventReadableHandle(HLERequestContext& ctx) {
99 LOG_WARNING(Service_AOC, "called");
100
101 IPC::ResponseBuilder rb{ctx, 2, 1};
102 rb.Push(ResultSuccess);
103 rb.PushCopyObjects(purchased_event->GetReadableEvent());
104 }
105
106 void PopPurchasedProductInfo(HLERequestContext& ctx) {
107 LOG_DEBUG(Service_AOC, "(STUBBED) called");
108
109 IPC::ResponseBuilder rb{ctx, 2};
110 rb.Push(ResultNoPurchasedProductInfoAvailable);
111 }
112
113 void PopPurchasedProductInfoWithUid(HLERequestContext& ctx) {
114 LOG_DEBUG(Service_AOC, "(STUBBED) called");
115
116 IPC::ResponseBuilder rb{ctx, 2};
117 rb.Push(ResultNoPurchasedProductInfoAvailable);
118 }
119
120 KernelHelpers::ServiceContext service_context;
121
122 Kernel::KEvent* purchased_event;
123};
124
125AOC_U::AOC_U(Core::System& system_)
126 : ServiceFramework{system_, "aoc:u"}, add_on_content{AccumulateAOCTitleIDs(system)},
127 service_context{system_, "aoc:u"} {
128 // clang-format off
129 static const FunctionInfo functions[] = {
130 {0, nullptr, "CountAddOnContentByApplicationId"},
131 {1, nullptr, "ListAddOnContentByApplicationId"},
132 {2, &AOC_U::CountAddOnContent, "CountAddOnContent"},
133 {3, &AOC_U::ListAddOnContent, "ListAddOnContent"},
134 {4, nullptr, "GetAddOnContentBaseIdByApplicationId"},
135 {5, &AOC_U::GetAddOnContentBaseId, "GetAddOnContentBaseId"},
136 {6, nullptr, "PrepareAddOnContentByApplicationId"},
137 {7, &AOC_U::PrepareAddOnContent, "PrepareAddOnContent"},
138 {8, &AOC_U::GetAddOnContentListChangedEvent, "GetAddOnContentListChangedEvent"},
139 {9, nullptr, "GetAddOnContentLostErrorCode"},
140 {10, &AOC_U::GetAddOnContentListChangedEventWithProcessId, "GetAddOnContentListChangedEventWithProcessId"},
141 {11, &AOC_U::NotifyMountAddOnContent, "NotifyMountAddOnContent"},
142 {12, &AOC_U::NotifyUnmountAddOnContent, "NotifyUnmountAddOnContent"},
143 {13, nullptr, "IsAddOnContentMountedForDebug"},
144 {50, &AOC_U::CheckAddOnContentMountStatus, "CheckAddOnContentMountStatus"},
145 {100, &AOC_U::CreateEcPurchasedEventManager, "CreateEcPurchasedEventManager"},
146 {101, &AOC_U::CreatePermanentEcPurchasedEventManager, "CreatePermanentEcPurchasedEventManager"},
147 {110, nullptr, "CreateContentsServiceManager"},
148 {200, nullptr, "SetRequiredAddOnContentsOnContentsAvailabilityTransition"},
149 {300, nullptr, "SetupHostAddOnContent"},
150 {301, nullptr, "GetRegisteredAddOnContentPath"},
151 {302, nullptr, "UpdateCachedList"},
152 };
153 // clang-format on
154
155 RegisterHandlers(functions);
156
157 aoc_change_event = service_context.CreateEvent("GetAddOnContentListChanged:Event");
158}
159
160AOC_U::~AOC_U() {
161 service_context.CloseEvent(aoc_change_event);
162}
163
164void AOC_U::CountAddOnContent(HLERequestContext& ctx) {
165 struct Parameters {
166 u64 process_id;
167 };
168 static_assert(sizeof(Parameters) == 8);
169
170 IPC::RequestParser rp{ctx};
171 const auto params = rp.PopRaw<Parameters>();
172
173 LOG_DEBUG(Service_AOC, "called. process_id={}", params.process_id);
174
175 IPC::ResponseBuilder rb{ctx, 3};
176 rb.Push(ResultSuccess);
177
178 const auto current = system.GetApplicationProcessProgramID();
179
180 const auto& disabled = Settings::values.disabled_addons[current];
181 if (std::find(disabled.begin(), disabled.end(), "DLC") != disabled.end()) {
182 rb.Push<u32>(0);
183 return;
184 }
185
186 rb.Push<u32>(static_cast<u32>(
187 std::count_if(add_on_content.begin(), add_on_content.end(),
188 [current](u64 tid) { return CheckAOCTitleIDMatchesBase(tid, current); })));
189}
190
191void AOC_U::ListAddOnContent(HLERequestContext& ctx) {
192 struct Parameters {
193 u32 offset;
194 u32 count;
195 u64 process_id;
196 };
197 static_assert(sizeof(Parameters) == 16);
198
199 IPC::RequestParser rp{ctx};
200 const auto [offset, count, process_id] = rp.PopRaw<Parameters>();
201
202 LOG_DEBUG(Service_AOC, "called with offset={}, count={}, process_id={}", offset, count,
203 process_id);
204
205 const auto current = FileSys::GetBaseTitleID(system.GetApplicationProcessProgramID());
206
207 std::vector<u32> out;
208 const auto& disabled = Settings::values.disabled_addons[current];
209 if (std::find(disabled.begin(), disabled.end(), "DLC") == disabled.end()) {
210 for (u64 content_id : add_on_content) {
211 if (FileSys::GetBaseTitleID(content_id) != current) {
212 continue;
213 }
214
215 out.push_back(static_cast<u32>(FileSys::GetAOCID(content_id)));
216 }
217 }
218
219 if (out.size() < offset) {
220 IPC::ResponseBuilder rb{ctx, 2};
221 // TODO(DarkLordZach): Find the correct error code.
222 rb.Push(ResultUnknown);
223 return;
224 }
225
226 const auto out_count = static_cast<u32>(std::min<size_t>(out.size() - offset, count));
227 std::rotate(out.begin(), out.begin() + offset, out.end());
228 out.resize(out_count);
229
230 ctx.WriteBuffer(out);
231
232 IPC::ResponseBuilder rb{ctx, 3};
233 rb.Push(ResultSuccess);
234 rb.Push(out_count);
235}
236
237void AOC_U::GetAddOnContentBaseId(HLERequestContext& ctx) {
238 struct Parameters {
239 u64 process_id;
240 };
241 static_assert(sizeof(Parameters) == 8);
242
243 IPC::RequestParser rp{ctx};
244 const auto params = rp.PopRaw<Parameters>();
245
246 LOG_DEBUG(Service_AOC, "called. process_id={}", params.process_id);
247
248 IPC::ResponseBuilder rb{ctx, 4};
249 rb.Push(ResultSuccess);
250
251 const auto title_id = system.GetApplicationProcessProgramID();
252 const FileSys::PatchManager pm{title_id, system.GetFileSystemController(),
253 system.GetContentProvider()};
254
255 const auto res = pm.GetControlMetadata();
256 if (res.first == nullptr) {
257 rb.Push(FileSys::GetAOCBaseTitleID(title_id));
258 return;
259 }
260
261 rb.Push(res.first->GetDLCBaseTitleId());
262}
263
264void AOC_U::PrepareAddOnContent(HLERequestContext& ctx) {
265 struct Parameters {
266 s32 addon_index;
267 u64 process_id;
268 };
269 static_assert(sizeof(Parameters) == 16);
270
271 IPC::RequestParser rp{ctx};
272 const auto [addon_index, process_id] = rp.PopRaw<Parameters>();
273
274 LOG_WARNING(Service_AOC, "(STUBBED) called with addon_index={}, process_id={}", addon_index,
275 process_id);
276
277 IPC::ResponseBuilder rb{ctx, 2};
278 rb.Push(ResultSuccess);
279}
280
281void AOC_U::GetAddOnContentListChangedEvent(HLERequestContext& ctx) {
282 LOG_WARNING(Service_AOC, "(STUBBED) called");
283
284 IPC::ResponseBuilder rb{ctx, 2, 1};
285 rb.Push(ResultSuccess);
286 rb.PushCopyObjects(aoc_change_event->GetReadableEvent());
287}
288
289void AOC_U::GetAddOnContentListChangedEventWithProcessId(HLERequestContext& ctx) {
290 LOG_WARNING(Service_AOC, "(STUBBED) called");
291
292 IPC::ResponseBuilder rb{ctx, 2, 1};
293 rb.Push(ResultSuccess);
294 rb.PushCopyObjects(aoc_change_event->GetReadableEvent());
295}
296
297void AOC_U::NotifyMountAddOnContent(HLERequestContext& ctx) {
298 LOG_WARNING(Service_AOC, "(STUBBED) called");
299
300 IPC::ResponseBuilder rb{ctx, 2};
301 rb.Push(ResultSuccess);
302}
303
304void AOC_U::NotifyUnmountAddOnContent(HLERequestContext& ctx) {
305 LOG_WARNING(Service_AOC, "(STUBBED) called");
306
307 IPC::ResponseBuilder rb{ctx, 2};
308 rb.Push(ResultSuccess);
309}
310
311void AOC_U::CheckAddOnContentMountStatus(HLERequestContext& ctx) {
312 LOG_WARNING(Service_AOC, "(STUBBED) called");
313
314 IPC::ResponseBuilder rb{ctx, 2};
315 rb.Push(ResultSuccess);
316}
317
318void AOC_U::CreateEcPurchasedEventManager(HLERequestContext& ctx) {
319 LOG_WARNING(Service_AOC, "(STUBBED) called");
320
321 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
322 rb.Push(ResultSuccess);
323 rb.PushIpcInterface<IPurchaseEventManager>(system);
324}
325
326void AOC_U::CreatePermanentEcPurchasedEventManager(HLERequestContext& ctx) {
327 LOG_WARNING(Service_AOC, "(STUBBED) called");
328
329 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
330 rb.Push(ResultSuccess);
331 rb.PushIpcInterface<IPurchaseEventManager>(system);
332}
333
334void LoopProcess(Core::System& system) {
335 auto server_manager = std::make_unique<ServerManager>(system);
336 server_manager->RegisterNamedService("aoc:u", std::make_shared<AOC_U>(system));
337 ServerManager::RunServer(std::move(server_manager));
338}
339
340} // namespace Service::AOC
diff --git a/src/core/hle/service/aoc/aoc_u.h b/src/core/hle/service/aoc/aoc_u.h
deleted file mode 100644
index 12ccfeb6a..000000000
--- a/src/core/hle/service/aoc/aoc_u.h
+++ /dev/null
@@ -1,45 +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 "core/hle/service/kernel_helpers.h"
7#include "core/hle/service/service.h"
8
9namespace Core {
10class System;
11}
12
13namespace Kernel {
14class KEvent;
15}
16
17namespace Service::AOC {
18
19class AOC_U final : public ServiceFramework<AOC_U> {
20public:
21 explicit AOC_U(Core::System& system);
22 ~AOC_U() override;
23
24private:
25 void CountAddOnContent(HLERequestContext& ctx);
26 void ListAddOnContent(HLERequestContext& ctx);
27 void GetAddOnContentBaseId(HLERequestContext& ctx);
28 void PrepareAddOnContent(HLERequestContext& ctx);
29 void GetAddOnContentListChangedEvent(HLERequestContext& ctx);
30 void GetAddOnContentListChangedEventWithProcessId(HLERequestContext& ctx);
31 void NotifyMountAddOnContent(HLERequestContext& ctx);
32 void NotifyUnmountAddOnContent(HLERequestContext& ctx);
33 void CheckAddOnContentMountStatus(HLERequestContext& ctx);
34 void CreateEcPurchasedEventManager(HLERequestContext& ctx);
35 void CreatePermanentEcPurchasedEventManager(HLERequestContext& ctx);
36
37 std::vector<u64> add_on_content;
38 KernelHelpers::ServiceContext service_context;
39
40 Kernel::KEvent* aoc_change_event;
41};
42
43void LoopProcess(Core::System& system);
44
45} // namespace Service::AOC
diff --git a/src/core/hle/service/aoc/purchase_event_manager.cpp b/src/core/hle/service/aoc/purchase_event_manager.cpp
new file mode 100644
index 000000000..9e718510b
--- /dev/null
+++ b/src/core/hle/service/aoc/purchase_event_manager.cpp
@@ -0,0 +1,67 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/aoc/purchase_event_manager.h"
5#include "core/hle/service/cmif_serialization.h"
6
7namespace Service::AOC {
8
9constexpr Result ResultNoPurchasedProductInfoAvailable{ErrorModule::NIMShop, 400};
10
11IPurchaseEventManager::IPurchaseEventManager(Core::System& system_)
12 : ServiceFramework{system_, "IPurchaseEventManager"}, service_context{system,
13 "IPurchaseEventManager"} {
14 // clang-format off
15 static const FunctionInfo functions[] = {
16 {0, D<&IPurchaseEventManager::SetDefaultDeliveryTarget>, "SetDefaultDeliveryTarget"},
17 {1, D<&IPurchaseEventManager::SetDeliveryTarget>, "SetDeliveryTarget"},
18 {2, D<&IPurchaseEventManager::GetPurchasedEvent>, "GetPurchasedEvent"},
19 {3, D<&IPurchaseEventManager::PopPurchasedProductInfo>, "PopPurchasedProductInfo"},
20 {4, D<&IPurchaseEventManager::PopPurchasedProductInfoWithUid>, "PopPurchasedProductInfoWithUid"},
21 };
22 // clang-format on
23
24 RegisterHandlers(functions);
25
26 purchased_event = service_context.CreateEvent("IPurchaseEventManager:PurchasedEvent");
27}
28
29IPurchaseEventManager::~IPurchaseEventManager() {
30 service_context.CloseEvent(purchased_event);
31}
32
33Result IPurchaseEventManager::SetDefaultDeliveryTarget(
34 ClientProcessId process_id, InBuffer<BufferAttr_HipcMapAlias> in_buffer) {
35 LOG_WARNING(Service_AOC, "(STUBBED) called, process_id={}", process_id.pid);
36
37 R_SUCCEED();
38}
39
40Result IPurchaseEventManager::SetDeliveryTarget(u64 unknown,
41 InBuffer<BufferAttr_HipcMapAlias> in_buffer) {
42 LOG_WARNING(Service_AOC, "(STUBBED) called, unknown={}", unknown);
43
44 R_SUCCEED();
45}
46
47Result IPurchaseEventManager::GetPurchasedEvent(OutCopyHandle<Kernel::KReadableEvent> out_event) {
48 LOG_WARNING(Service_AOC, "called");
49
50 *out_event = &purchased_event->GetReadableEvent();
51
52 R_SUCCEED();
53}
54
55Result IPurchaseEventManager::PopPurchasedProductInfo() {
56 LOG_DEBUG(Service_AOC, "(STUBBED) called");
57
58 R_RETURN(ResultNoPurchasedProductInfoAvailable);
59}
60
61Result IPurchaseEventManager::PopPurchasedProductInfoWithUid() {
62 LOG_DEBUG(Service_AOC, "(STUBBED) called");
63
64 R_RETURN(ResultNoPurchasedProductInfoAvailable);
65}
66
67} // namespace Service::AOC
diff --git a/src/core/hle/service/aoc/purchase_event_manager.h b/src/core/hle/service/aoc/purchase_event_manager.h
new file mode 100644
index 000000000..ea3836bc9
--- /dev/null
+++ b/src/core/hle/service/aoc/purchase_event_manager.h
@@ -0,0 +1,30 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include "core/hle/service/cmif_types.h"
7#include "core/hle/service/kernel_helpers.h"
8#include "core/hle/service/os/event.h"
9#include "core/hle/service/service.h"
10
11namespace Service::AOC {
12
13class IPurchaseEventManager final : public ServiceFramework<IPurchaseEventManager> {
14public:
15 explicit IPurchaseEventManager(Core::System& system_);
16 ~IPurchaseEventManager() override;
17
18 Result SetDefaultDeliveryTarget(ClientProcessId process_id,
19 InBuffer<BufferAttr_HipcMapAlias> in_buffer);
20 Result SetDeliveryTarget(u64 unknown, InBuffer<BufferAttr_HipcMapAlias> in_buffer);
21 Result GetPurchasedEvent(OutCopyHandle<Kernel::KReadableEvent> out_event);
22 Result PopPurchasedProductInfo();
23 Result PopPurchasedProductInfoWithUid();
24
25private:
26 KernelHelpers::ServiceContext service_context;
27 Kernel::KEvent* purchased_event;
28};
29
30} // namespace Service::AOC
diff --git a/src/core/hle/service/audio/audio_controller.cpp b/src/core/hle/service/audio/audio_controller.cpp
index c9804cf9c..7a51d1023 100644
--- a/src/core/hle/service/audio/audio_controller.cpp
+++ b/src/core/hle/service/audio/audio_controller.cpp
@@ -138,7 +138,7 @@ Result IAudioController::SetOutputModeSetting(Set::AudioOutputModeTarget target,
138} 138}
139 139
140Result IAudioController::SetHeadphoneOutputLevelMode(HeadphoneOutputLevelMode output_level_mode) { 140Result IAudioController::SetHeadphoneOutputLevelMode(HeadphoneOutputLevelMode output_level_mode) {
141 LOG_WARNING(Audio, "(STUBBED) called"); 141 LOG_WARNING(Audio, "(STUBBED) called, output_level_mode={}", output_level_mode);
142 R_SUCCEED(); 142 R_SUCCEED();
143} 143}
144 144
diff --git a/src/core/hle/service/btdrv/btdrv.cpp b/src/core/hle/service/btdrv/btdrv.cpp
index 38cdd57ad..83618a956 100644
--- a/src/core/hle/service/btdrv/btdrv.cpp
+++ b/src/core/hle/service/btdrv/btdrv.cpp
@@ -5,6 +5,7 @@
5#include "core/core.h" 5#include "core/core.h"
6#include "core/hle/kernel/k_event.h" 6#include "core/hle/kernel/k_event.h"
7#include "core/hle/service/btdrv/btdrv.h" 7#include "core/hle/service/btdrv/btdrv.h"
8#include "core/hle/service/cmif_serialization.h"
8#include "core/hle/service/ipc_helpers.h" 9#include "core/hle/service/ipc_helpers.h"
9#include "core/hle/service/kernel_helpers.h" 10#include "core/hle/service/kernel_helpers.h"
10#include "core/hle/service/server_manager.h" 11#include "core/hle/service/server_manager.h"
@@ -13,9 +14,9 @@
13 14
14namespace Service::BtDrv { 15namespace Service::BtDrv {
15 16
16class Bt final : public ServiceFramework<Bt> { 17class IBluetoothUser final : public ServiceFramework<IBluetoothUser> {
17public: 18public:
18 explicit Bt(Core::System& system_) 19 explicit IBluetoothUser(Core::System& system_)
19 : ServiceFramework{system_, "bt"}, service_context{system_, "bt"} { 20 : ServiceFramework{system_, "bt"}, service_context{system_, "bt"} {
20 // clang-format off 21 // clang-format off
21 static const FunctionInfo functions[] = { 22 static const FunctionInfo functions[] = {
@@ -28,7 +29,7 @@ public:
28 {6, nullptr, "SetLeResponse"}, 29 {6, nullptr, "SetLeResponse"},
29 {7, nullptr, "LeSendIndication"}, 30 {7, nullptr, "LeSendIndication"},
30 {8, nullptr, "GetLeEventInfo"}, 31 {8, nullptr, "GetLeEventInfo"},
31 {9, &Bt::RegisterBleEvent, "RegisterBleEvent"}, 32 {9, C<&IBluetoothUser::RegisterBleEvent>, "RegisterBleEvent"},
32 }; 33 };
33 // clang-format on 34 // clang-format on
34 RegisterHandlers(functions); 35 RegisterHandlers(functions);
@@ -36,17 +37,16 @@ public:
36 register_event = service_context.CreateEvent("BT:RegisterEvent"); 37 register_event = service_context.CreateEvent("BT:RegisterEvent");
37 } 38 }
38 39
39 ~Bt() override { 40 ~IBluetoothUser() override {
40 service_context.CloseEvent(register_event); 41 service_context.CloseEvent(register_event);
41 } 42 }
42 43
43private: 44private:
44 void RegisterBleEvent(HLERequestContext& ctx) { 45 Result RegisterBleEvent(OutCopyHandle<Kernel::KReadableEvent> out_event) {
45 LOG_WARNING(Service_BTM, "(STUBBED) called"); 46 LOG_WARNING(Service_BTM, "(STUBBED) called");
46 47
47 IPC::ResponseBuilder rb{ctx, 2, 1}; 48 *out_event = &register_event->GetReadableEvent();
48 rb.Push(ResultSuccess); 49 R_SUCCEED();
49 rb.PushCopyObjects(register_event->GetReadableEvent());
50 } 50 }
51 51
52 KernelHelpers::ServiceContext service_context; 52 KernelHelpers::ServiceContext service_context;
@@ -54,9 +54,9 @@ private:
54 Kernel::KEvent* register_event; 54 Kernel::KEvent* register_event;
55}; 55};
56 56
57class BtDrv final : public ServiceFramework<BtDrv> { 57class IBluetoothDriver final : public ServiceFramework<IBluetoothDriver> {
58public: 58public:
59 explicit BtDrv(Core::System& system_) : ServiceFramework{system_, "btdrv"} { 59 explicit IBluetoothDriver(Core::System& system_) : ServiceFramework{system_, "btdrv"} {
60 // clang-format off 60 // clang-format off
61 static const FunctionInfo functions[] = { 61 static const FunctionInfo functions[] = {
62 {0, nullptr, "InitializeBluetoothDriver"}, 62 {0, nullptr, "InitializeBluetoothDriver"},
@@ -93,7 +93,7 @@ public:
93 {31, nullptr, "EnableMcMode"}, 93 {31, nullptr, "EnableMcMode"},
94 {32, nullptr, "EnableLlrScan"}, 94 {32, nullptr, "EnableLlrScan"},
95 {33, nullptr, "DisableLlrScan"}, 95 {33, nullptr, "DisableLlrScan"},
96 {34, nullptr, "EnableRadio"}, 96 {34, C<&IBluetoothDriver::EnableRadio>, "EnableRadio"},
97 {35, nullptr, "SetVisibility"}, 97 {35, nullptr, "SetVisibility"},
98 {36, nullptr, "EnableTbfcScan"}, 98 {36, nullptr, "EnableTbfcScan"},
99 {37, nullptr, "RegisterHidReportEvent"}, 99 {37, nullptr, "RegisterHidReportEvent"},
@@ -195,13 +195,19 @@ public:
195 195
196 RegisterHandlers(functions); 196 RegisterHandlers(functions);
197 } 197 }
198
199private:
200 Result EnableRadio() {
201 LOG_WARNING(Service_BTDRV, "(STUBBED) called");
202 R_SUCCEED();
203 }
198}; 204};
199 205
200void LoopProcess(Core::System& system) { 206void LoopProcess(Core::System& system) {
201 auto server_manager = std::make_unique<ServerManager>(system); 207 auto server_manager = std::make_unique<ServerManager>(system);
202 208
203 server_manager->RegisterNamedService("btdrv", std::make_shared<BtDrv>(system)); 209 server_manager->RegisterNamedService("btdrv", std::make_shared<IBluetoothDriver>(system));
204 server_manager->RegisterNamedService("bt", std::make_shared<Bt>(system)); 210 server_manager->RegisterNamedService("bt", std::make_shared<IBluetoothUser>(system));
205 ServerManager::RunServer(std::move(server_manager)); 211 ServerManager::RunServer(std::move(server_manager));
206} 212}
207 213
diff --git a/src/core/hle/service/erpt/erpt.cpp b/src/core/hle/service/erpt/erpt.cpp
index 39ae3a723..6b7eab5ef 100644
--- a/src/core/hle/service/erpt/erpt.cpp
+++ b/src/core/hle/service/erpt/erpt.cpp
@@ -18,7 +18,7 @@ public:
18 // clang-format off 18 // clang-format off
19 static const FunctionInfo functions[] = { 19 static const FunctionInfo functions[] = {
20 {0, C<&ErrorReportContext::SubmitContext>, "SubmitContext"}, 20 {0, C<&ErrorReportContext::SubmitContext>, "SubmitContext"},
21 {1, nullptr, "CreateReportV0"}, 21 {1, C<&ErrorReportContext::CreateReportV0>, "CreateReportV0"},
22 {2, nullptr, "SetInitialLaunchSettingsCompletionTime"}, 22 {2, nullptr, "SetInitialLaunchSettingsCompletionTime"},
23 {3, nullptr, "ClearInitialLaunchSettingsCompletionTime"}, 23 {3, nullptr, "ClearInitialLaunchSettingsCompletionTime"},
24 {4, nullptr, "UpdatePowerOnTime"}, 24 {4, nullptr, "UpdatePowerOnTime"},
@@ -28,7 +28,8 @@ public:
28 {8, nullptr, "ClearApplicationLaunchTime"}, 28 {8, nullptr, "ClearApplicationLaunchTime"},
29 {9, nullptr, "SubmitAttachment"}, 29 {9, nullptr, "SubmitAttachment"},
30 {10, nullptr, "CreateReportWithAttachments"}, 30 {10, nullptr, "CreateReportWithAttachments"},
31 {11, nullptr, "CreateReport"}, 31 {11, C<&ErrorReportContext::CreateReportV1>, "CreateReportV1"},
32 {12, C<&ErrorReportContext::CreateReport>, "CreateReport"},
32 {20, nullptr, "RegisterRunningApplet"}, 33 {20, nullptr, "RegisterRunningApplet"},
33 {21, nullptr, "UnregisterRunningApplet"}, 34 {21, nullptr, "UnregisterRunningApplet"},
34 {22, nullptr, "UpdateAppletSuspendedDuration"}, 35 {22, nullptr, "UpdateAppletSuspendedDuration"},
@@ -40,10 +41,37 @@ public:
40 } 41 }
41 42
42private: 43private:
43 Result SubmitContext(InBuffer<BufferAttr_HipcMapAlias> buffer_a, 44 Result SubmitContext(InBuffer<BufferAttr_HipcMapAlias> context_entry,
44 InBuffer<BufferAttr_HipcMapAlias> buffer_b) { 45 InBuffer<BufferAttr_HipcMapAlias> field_list) {
45 LOG_WARNING(Service_SET, "(STUBBED) called, buffer_a_size={}, buffer_b_size={}", 46 LOG_WARNING(Service_SET, "(STUBBED) called, context_entry_size={}, field_list_size={}",
46 buffer_a.size(), buffer_b.size()); 47 context_entry.size(), field_list.size());
48 R_SUCCEED();
49 }
50
51 Result CreateReportV0(u32 report_type, InBuffer<BufferAttr_HipcMapAlias> context_entry,
52 InBuffer<BufferAttr_HipcMapAlias> report_list,
53 InBuffer<BufferAttr_HipcMapAlias> report_meta_data) {
54 LOG_WARNING(Service_SET, "(STUBBED) called, report_type={:#x}", report_type);
55 R_SUCCEED();
56 }
57
58 Result CreateReportV1(u32 report_type, u32 unknown,
59 InBuffer<BufferAttr_HipcMapAlias> context_entry,
60 InBuffer<BufferAttr_HipcMapAlias> report_list,
61 InBuffer<BufferAttr_HipcMapAlias> report_meta_data) {
62 LOG_WARNING(Service_SET, "(STUBBED) called, report_type={:#x}, unknown={:#x}", report_type,
63 unknown);
64 R_SUCCEED();
65 }
66
67 Result CreateReport(u32 report_type, u32 unknown, u32 create_report_option_flag,
68 InBuffer<BufferAttr_HipcMapAlias> context_entry,
69 InBuffer<BufferAttr_HipcMapAlias> report_list,
70 InBuffer<BufferAttr_HipcMapAlias> report_meta_data) {
71 LOG_WARNING(
72 Service_SET,
73 "(STUBBED) called, report_type={:#x}, unknown={:#x}, create_report_option_flag={:#x}",
74 report_type, unknown, create_report_option_flag);
47 R_SUCCEED(); 75 R_SUCCEED();
48 } 76 }
49}; 77};
diff --git a/src/core/hle/service/filesystem/fsp/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp/fsp_srv.cpp
index 223284255..60290f1a6 100644
--- a/src/core/hle/service/filesystem/fsp/fsp_srv.cpp
+++ b/src/core/hle/service/filesystem/fsp/fsp_srv.cpp
@@ -71,7 +71,7 @@ FSP_SRV::FSP_SRV(Core::System& system_)
71 {28, nullptr, "DeleteSaveDataFileSystemBySaveDataAttribute"}, 71 {28, nullptr, "DeleteSaveDataFileSystemBySaveDataAttribute"},
72 {30, nullptr, "OpenGameCardStorage"}, 72 {30, nullptr, "OpenGameCardStorage"},
73 {31, nullptr, "OpenGameCardFileSystem"}, 73 {31, nullptr, "OpenGameCardFileSystem"},
74 {32, nullptr, "ExtendSaveDataFileSystem"}, 74 {32, D<&FSP_SRV::ExtendSaveDataFileSystem>, "ExtendSaveDataFileSystem"},
75 {33, nullptr, "DeleteCacheStorage"}, 75 {33, nullptr, "DeleteCacheStorage"},
76 {34, D<&FSP_SRV::GetCacheStorageSize>, "GetCacheStorageSize"}, 76 {34, D<&FSP_SRV::GetCacheStorageSize>, "GetCacheStorageSize"},
77 {35, nullptr, "CreateSaveDataFileSystemByHashSalt"}, 77 {35, nullptr, "CreateSaveDataFileSystemByHashSalt"},
@@ -79,9 +79,9 @@ FSP_SRV::FSP_SRV(Core::System& system_)
79 {51, D<&FSP_SRV::OpenSaveDataFileSystem>, "OpenSaveDataFileSystem"}, 79 {51, D<&FSP_SRV::OpenSaveDataFileSystem>, "OpenSaveDataFileSystem"},
80 {52, D<&FSP_SRV::OpenSaveDataFileSystemBySystemSaveDataId>, "OpenSaveDataFileSystemBySystemSaveDataId"}, 80 {52, D<&FSP_SRV::OpenSaveDataFileSystemBySystemSaveDataId>, "OpenSaveDataFileSystemBySystemSaveDataId"},
81 {53, D<&FSP_SRV::OpenReadOnlySaveDataFileSystem>, "OpenReadOnlySaveDataFileSystem"}, 81 {53, D<&FSP_SRV::OpenReadOnlySaveDataFileSystem>, "OpenReadOnlySaveDataFileSystem"},
82 {57, nullptr, "ReadSaveDataFileSystemExtraDataBySaveDataSpaceId"}, 82 {57, D<&FSP_SRV::ReadSaveDataFileSystemExtraDataBySaveDataSpaceId>, "ReadSaveDataFileSystemExtraDataBySaveDataSpaceId"},
83 {58, nullptr, "ReadSaveDataFileSystemExtraData"}, 83 {58, D<&FSP_SRV::ReadSaveDataFileSystemExtraData>, "ReadSaveDataFileSystemExtraData"},
84 {59, nullptr, "WriteSaveDataFileSystemExtraData"}, 84 {59, D<&FSP_SRV::WriteSaveDataFileSystemExtraData>, "WriteSaveDataFileSystemExtraData"},
85 {60, nullptr, "OpenSaveDataInfoReader"}, 85 {60, nullptr, "OpenSaveDataInfoReader"},
86 {61, D<&FSP_SRV::OpenSaveDataInfoReaderBySaveDataSpaceId>, "OpenSaveDataInfoReaderBySaveDataSpaceId"}, 86 {61, D<&FSP_SRV::OpenSaveDataInfoReaderBySaveDataSpaceId>, "OpenSaveDataInfoReaderBySaveDataSpaceId"},
87 {62, D<&FSP_SRV::OpenSaveDataInfoReaderOnlyCacheStorage>, "OpenSaveDataInfoReaderOnlyCacheStorage"}, 87 {62, D<&FSP_SRV::OpenSaveDataInfoReaderOnlyCacheStorage>, "OpenSaveDataInfoReaderOnlyCacheStorage"},
@@ -90,8 +90,8 @@ FSP_SRV::FSP_SRV(Core::System& system_)
90 {66, nullptr, "WriteSaveDataFileSystemExtraData2"}, 90 {66, nullptr, "WriteSaveDataFileSystemExtraData2"},
91 {67, D<&FSP_SRV::FindSaveDataWithFilter>, "FindSaveDataWithFilter"}, 91 {67, D<&FSP_SRV::FindSaveDataWithFilter>, "FindSaveDataWithFilter"},
92 {68, nullptr, "OpenSaveDataInfoReaderBySaveDataFilter"}, 92 {68, nullptr, "OpenSaveDataInfoReaderBySaveDataFilter"},
93 {69, nullptr, "ReadSaveDataFileSystemExtraDataBySaveDataAttribute"}, 93 {69, D<&FSP_SRV::ReadSaveDataFileSystemExtraDataBySaveDataAttribute>, "ReadSaveDataFileSystemExtraDataBySaveDataAttribute"},
94 {70, D<&FSP_SRV::WriteSaveDataFileSystemExtraDataBySaveDataAttribute>, "WriteSaveDataFileSystemExtraDataBySaveDataAttribute"}, 94 {70, D<&FSP_SRV::WriteSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute>, "WriteSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute"},
95 {71, D<&FSP_SRV::ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute>, "ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute"}, 95 {71, D<&FSP_SRV::ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute>, "ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute"},
96 {80, nullptr, "OpenSaveDataMetaFile"}, 96 {80, nullptr, "OpenSaveDataMetaFile"},
97 {81, nullptr, "OpenSaveDataTransferManager"}, 97 {81, nullptr, "OpenSaveDataTransferManager"},
@@ -317,9 +317,23 @@ Result FSP_SRV::FindSaveDataWithFilter(Out<s64> out_count,
317 R_THROW(FileSys::ResultTargetNotFound); 317 R_THROW(FileSys::ResultTargetNotFound);
318} 318}
319 319
320Result FSP_SRV::WriteSaveDataFileSystemExtraDataBySaveDataAttribute() { 320Result FSP_SRV::WriteSaveDataFileSystemExtraData(InBuffer<BufferAttr_HipcMapAlias> buffer,
321 LOG_WARNING(Service_FS, "(STUBBED) called."); 321 FileSys::SaveDataSpaceId space_id,
322 u64 save_data_id) {
323 LOG_WARNING(Service_FS, "(STUBBED) called, space_id={}, save_data_id={:016X}", space_id,
324 save_data_id);
325 R_SUCCEED();
326}
322 327
328Result FSP_SRV::WriteSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute(
329 InBuffer<BufferAttr_HipcMapAlias> buffer, InBuffer<BufferAttr_HipcMapAlias> mask_buffer,
330 FileSys::SaveDataSpaceId space_id, FileSys::SaveDataAttribute attribute) {
331 LOG_WARNING(Service_FS,
332 "(STUBBED) called, space_id={}, attribute.program_id={:016X}\n"
333 "attribute.user_id={:016X}{:016X}, attribute.save_id={:016X}\n"
334 "attribute.type={}, attribute.rank={}, attribute.index={}",
335 space_id, attribute.program_id, attribute.user_id[1], attribute.user_id[0],
336 attribute.system_save_data_id, attribute.type, attribute.rank, attribute.index);
323 R_SUCCEED(); 337 R_SUCCEED();
324} 338}
325 339
@@ -341,6 +355,38 @@ Result FSP_SRV::ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute(
341 R_SUCCEED(); 355 R_SUCCEED();
342} 356}
343 357
358Result FSP_SRV::ReadSaveDataFileSystemExtraData(OutBuffer<BufferAttr_HipcMapAlias> out_buffer,
359 u64 save_data_id) {
360 // Stub, backend needs an impl to read/write the SaveDataExtraData
361 LOG_WARNING(Service_FS, "(STUBBED) called, save_data_id={:016X}", save_data_id);
362 std::memset(out_buffer.data(), 0, out_buffer.size());
363 R_SUCCEED();
364}
365
366Result FSP_SRV::ReadSaveDataFileSystemExtraDataBySaveDataAttribute(
367 OutBuffer<BufferAttr_HipcMapAlias> out_buffer, FileSys::SaveDataSpaceId space_id,
368 FileSys::SaveDataAttribute attribute) {
369 // Stub, backend needs an impl to read/write the SaveDataExtraData
370 LOG_WARNING(Service_FS,
371 "(STUBBED) called, space_id={}, attribute.program_id={:016X}\n"
372 "attribute.user_id={:016X}{:016X}, attribute.save_id={:016X}\n"
373 "attribute.type={}, attribute.rank={}, attribute.index={}",
374 space_id, attribute.program_id, attribute.user_id[1], attribute.user_id[0],
375 attribute.system_save_data_id, attribute.type, attribute.rank, attribute.index);
376 std::memset(out_buffer.data(), 0, out_buffer.size());
377 R_SUCCEED();
378}
379
380Result FSP_SRV::ReadSaveDataFileSystemExtraDataBySaveDataSpaceId(
381 OutBuffer<BufferAttr_HipcMapAlias> out_buffer, FileSys::SaveDataSpaceId space_id,
382 u64 save_data_id) {
383 // Stub, backend needs an impl to read/write the SaveDataExtraData
384 LOG_WARNING(Service_FS, "(STUBBED) called, space_id={}, save_data_id={:016X}", space_id,
385 save_data_id);
386 std::memset(out_buffer.data(), 0, out_buffer.size());
387 R_SUCCEED();
388}
389
344Result FSP_SRV::OpenSaveDataTransferProhibiter( 390Result FSP_SRV::OpenSaveDataTransferProhibiter(
345 OutInterface<ISaveDataTransferProhibiter> out_prohibiter, u64 id) { 391 OutInterface<ISaveDataTransferProhibiter> out_prohibiter, u64 id) {
346 LOG_WARNING(Service_FS, "(STUBBED) called, id={:016X}", id); 392 LOG_WARNING(Service_FS, "(STUBBED) called, id={:016X}", id);
@@ -476,6 +522,16 @@ Result FSP_SRV::FlushAccessLogOnSdCard() {
476 R_SUCCEED(); 522 R_SUCCEED();
477} 523}
478 524
525Result FSP_SRV::ExtendSaveDataFileSystem(FileSys::SaveDataSpaceId space_id, u64 save_data_id,
526 s64 available_size, s64 journal_size) {
527 // We don't have an index of save data ids, so we can't implement this.
528 LOG_WARNING(Service_FS,
529 "(STUBBED) called, space_id={}, save_data_id={:016X}, available_size={:#x}, "
530 "journal_size={:#x}",
531 space_id, save_data_id, available_size, journal_size);
532 R_SUCCEED();
533}
534
479Result FSP_SRV::GetCacheStorageSize(s32 index, Out<s64> out_data_size, Out<s64> out_journal_size) { 535Result FSP_SRV::GetCacheStorageSize(s32 index, Out<s64> out_data_size, Out<s64> out_journal_size) {
480 LOG_WARNING(Service_FS, "(STUBBED) called with index={}", index); 536 LOG_WARNING(Service_FS, "(STUBBED) called with index={}", index);
481 537
diff --git a/src/core/hle/service/filesystem/fsp/fsp_srv.h b/src/core/hle/service/filesystem/fsp/fsp_srv.h
index 83d9cb51c..b565cace0 100644
--- a/src/core/hle/service/filesystem/fsp/fsp_srv.h
+++ b/src/core/hle/service/filesystem/fsp/fsp_srv.h
@@ -70,7 +70,19 @@ private:
70 Result FindSaveDataWithFilter(Out<s64> out_count, OutBuffer<BufferAttr_HipcMapAlias> out_buffer, 70 Result FindSaveDataWithFilter(Out<s64> out_count, OutBuffer<BufferAttr_HipcMapAlias> out_buffer,
71 FileSys::SaveDataSpaceId space_id, 71 FileSys::SaveDataSpaceId space_id,
72 FileSys::SaveDataFilter filter); 72 FileSys::SaveDataFilter filter);
73 Result WriteSaveDataFileSystemExtraDataBySaveDataAttribute(); 73 Result WriteSaveDataFileSystemExtraData(InBuffer<BufferAttr_HipcMapAlias> buffer,
74 FileSys::SaveDataSpaceId space_id, u64 save_data_id);
75 Result WriteSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute(
76 InBuffer<BufferAttr_HipcMapAlias> buffer, InBuffer<BufferAttr_HipcMapAlias> mask_buffer,
77 FileSys::SaveDataSpaceId space_id, FileSys::SaveDataAttribute attribute);
78 Result ReadSaveDataFileSystemExtraData(OutBuffer<BufferAttr_HipcMapAlias> out_buffer,
79 u64 save_data_id);
80 Result ReadSaveDataFileSystemExtraDataBySaveDataAttribute(
81 OutBuffer<BufferAttr_HipcMapAlias> out_buffer, FileSys::SaveDataSpaceId space_id,
82 FileSys::SaveDataAttribute attribute);
83 Result ReadSaveDataFileSystemExtraDataBySaveDataSpaceId(
84 OutBuffer<BufferAttr_HipcMapAlias> out_buffer, FileSys::SaveDataSpaceId space_id,
85 u64 save_data_id);
74 Result ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute( 86 Result ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute(
75 FileSys::SaveDataSpaceId space_id, FileSys::SaveDataAttribute attribute, 87 FileSys::SaveDataSpaceId space_id, FileSys::SaveDataAttribute attribute,
76 InBuffer<BufferAttr_HipcMapAlias> mask_buffer, 88 InBuffer<BufferAttr_HipcMapAlias> mask_buffer,
@@ -91,6 +103,8 @@ private:
91 Result GetProgramIndexForAccessLog(Out<AccessLogVersion> out_access_log_version, 103 Result GetProgramIndexForAccessLog(Out<AccessLogVersion> out_access_log_version,
92 Out<u32> out_access_log_program_index); 104 Out<u32> out_access_log_program_index);
93 Result OpenMultiCommitManager(OutInterface<IMultiCommitManager> out_interface); 105 Result OpenMultiCommitManager(OutInterface<IMultiCommitManager> out_interface);
106 Result ExtendSaveDataFileSystem(FileSys::SaveDataSpaceId space_id, u64 save_data_id,
107 s64 available_size, s64 journal_size);
94 Result GetCacheStorageSize(s32 index, Out<s64> out_data_size, Out<s64> out_journal_size); 108 Result GetCacheStorageSize(s32 index, Out<s64> out_data_size, Out<s64> out_journal_size);
95 109
96 FileSystemController& fsc; 110 FileSystemController& fsc;
diff --git a/src/core/hle/service/friend/friend.cpp b/src/core/hle/service/friend/friend.cpp
index aeb849efa..38e62761b 100644
--- a/src/core/hle/service/friend/friend.cpp
+++ b/src/core/hle/service/friend/friend.cpp
@@ -42,13 +42,13 @@ public:
42 {10701, nullptr, "GetPlayHistoryRegistrationKeyWithNetworkServiceAccountId"}, 42 {10701, nullptr, "GetPlayHistoryRegistrationKeyWithNetworkServiceAccountId"},
43 {10702, nullptr, "AddPlayHistory"}, 43 {10702, nullptr, "AddPlayHistory"},
44 {11000, nullptr, "GetProfileImageUrl"}, 44 {11000, nullptr, "GetProfileImageUrl"},
45 {20100, nullptr, "GetFriendCount"}, 45 {20100, &IFriendService::GetFriendCount, "GetFriendCount"},
46 {20101, nullptr, "GetNewlyFriendCount"}, 46 {20101, &IFriendService::GetNewlyFriendCount, "GetNewlyFriendCount"},
47 {20102, nullptr, "GetFriendDetailedInfo"}, 47 {20102, nullptr, "GetFriendDetailedInfo"},
48 {20103, nullptr, "SyncFriendList"}, 48 {20103, nullptr, "SyncFriendList"},
49 {20104, nullptr, "RequestSyncFriendList"}, 49 {20104, nullptr, "RequestSyncFriendList"},
50 {20110, nullptr, "LoadFriendSetting"}, 50 {20110, nullptr, "LoadFriendSetting"},
51 {20200, nullptr, "GetReceivedFriendRequestCount"}, 51 {20200, &IFriendService::GetReceivedFriendRequestCount, "GetReceivedFriendRequestCount"},
52 {20201, nullptr, "GetFriendRequestList"}, 52 {20201, nullptr, "GetFriendRequestList"},
53 {20300, nullptr, "GetFriendCandidateList"}, 53 {20300, nullptr, "GetFriendCandidateList"},
54 {20301, nullptr, "GetNintendoNetworkIdInfo"}, 54 {20301, nullptr, "GetNintendoNetworkIdInfo"},
@@ -61,14 +61,14 @@ public:
61 {20501, nullptr, "GetRelationship"}, 61 {20501, nullptr, "GetRelationship"},
62 {20600, nullptr, "GetUserPresenceView"}, 62 {20600, nullptr, "GetUserPresenceView"},
63 {20700, nullptr, "GetPlayHistoryList"}, 63 {20700, nullptr, "GetPlayHistoryList"},
64 {20701, nullptr, "GetPlayHistoryStatistics"}, 64 {20701, &IFriendService::GetPlayHistoryStatistics, "GetPlayHistoryStatistics"},
65 {20800, nullptr, "LoadUserSetting"}, 65 {20800, nullptr, "LoadUserSetting"},
66 {20801, nullptr, "SyncUserSetting"}, 66 {20801, nullptr, "SyncUserSetting"},
67 {20900, nullptr, "RequestListSummaryOverlayNotification"}, 67 {20900, nullptr, "RequestListSummaryOverlayNotification"},
68 {21000, nullptr, "GetExternalApplicationCatalog"}, 68 {21000, nullptr, "GetExternalApplicationCatalog"},
69 {22000, nullptr, "GetReceivedFriendInvitationList"}, 69 {22000, nullptr, "GetReceivedFriendInvitationList"},
70 {22001, nullptr, "GetReceivedFriendInvitationDetailedInfo"}, 70 {22001, nullptr, "GetReceivedFriendInvitationDetailedInfo"},
71 {22010, nullptr, "GetReceivedFriendInvitationCountCache"}, 71 {22010, &IFriendService::GetReceivedFriendInvitationCountCache, "GetReceivedFriendInvitationCountCache"},
72 {30100, nullptr, "DropFriendNewlyFlags"}, 72 {30100, nullptr, "DropFriendNewlyFlags"},
73 {30101, nullptr, "DeleteFriend"}, 73 {30101, nullptr, "DeleteFriend"},
74 {30110, nullptr, "DropFriendNewlyFlag"}, 74 {30110, nullptr, "DropFriendNewlyFlag"},
@@ -144,6 +144,33 @@ private:
144 rb.PushCopyObjects(completion_event->GetReadableEvent()); 144 rb.PushCopyObjects(completion_event->GetReadableEvent());
145 } 145 }
146 146
147 void GetFriendList(HLERequestContext& ctx) {
148 IPC::RequestParser rp{ctx};
149 const auto friend_offset = rp.Pop<u32>();
150 const auto uuid = rp.PopRaw<Common::UUID>();
151 [[maybe_unused]] const auto filter = rp.PopRaw<SizedFriendFilter>();
152 const auto pid = rp.Pop<u64>();
153 LOG_WARNING(Service_Friend, "(STUBBED) called, offset={}, uuid=0x{}, pid={}", friend_offset,
154 uuid.RawString(), pid);
155
156 IPC::ResponseBuilder rb{ctx, 3};
157 rb.Push(ResultSuccess);
158
159 rb.Push<u32>(0); // Friend count
160 // TODO(ogniK): Return a buffer of u64s which are the "NetworkServiceAccountId"
161 }
162
163 void CheckFriendListAvailability(HLERequestContext& ctx) {
164 IPC::RequestParser rp{ctx};
165 const auto uuid{rp.PopRaw<Common::UUID>()};
166
167 LOG_WARNING(Service_Friend, "(STUBBED) called, uuid=0x{}", uuid.RawString());
168
169 IPC::ResponseBuilder rb{ctx, 3};
170 rb.Push(ResultSuccess);
171 rb.Push(true);
172 }
173
147 void GetBlockedUserListIds(HLERequestContext& ctx) { 174 void GetBlockedUserListIds(HLERequestContext& ctx) {
148 // This is safe to stub, as there should be no adverse consequences from reporting no 175 // This is safe to stub, as there should be no adverse consequences from reporting no
149 // blocked users. 176 // blocked users.
@@ -153,6 +180,17 @@ private:
153 rb.Push<u32>(0); // Indicates there are no blocked users 180 rb.Push<u32>(0); // Indicates there are no blocked users
154 } 181 }
155 182
183 void CheckBlockedUserListAvailability(HLERequestContext& ctx) {
184 IPC::RequestParser rp{ctx};
185 const auto uuid{rp.PopRaw<Common::UUID>()};
186
187 LOG_WARNING(Service_Friend, "(STUBBED) called, uuid=0x{}", uuid.RawString());
188
189 IPC::ResponseBuilder rb{ctx, 3};
190 rb.Push(ResultSuccess);
191 rb.Push(true);
192 }
193
156 void DeclareCloseOnlinePlaySession(HLERequestContext& ctx) { 194 void DeclareCloseOnlinePlaySession(HLERequestContext& ctx) {
157 // Stub used by Splatoon 2 195 // Stub used by Splatoon 2
158 LOG_WARNING(Service_Friend, "(STUBBED) called"); 196 LOG_WARNING(Service_Friend, "(STUBBED) called");
@@ -179,42 +217,43 @@ private:
179 rb.Push(ResultSuccess); 217 rb.Push(ResultSuccess);
180 } 218 }
181 219
182 void GetFriendList(HLERequestContext& ctx) { 220 void GetFriendCount(HLERequestContext& ctx) {
183 IPC::RequestParser rp{ctx}; 221 LOG_DEBUG(Service_Friend, "(STUBBED) called");
184 const auto friend_offset = rp.Pop<u32>();
185 const auto uuid = rp.PopRaw<Common::UUID>();
186 [[maybe_unused]] const auto filter = rp.PopRaw<SizedFriendFilter>();
187 const auto pid = rp.Pop<u64>();
188 LOG_WARNING(Service_Friend, "(STUBBED) called, offset={}, uuid=0x{}, pid={}", friend_offset,
189 uuid.RawString(), pid);
190 222
191 IPC::ResponseBuilder rb{ctx, 3}; 223 IPC::ResponseBuilder rb{ctx, 3};
192 rb.Push(ResultSuccess); 224 rb.Push(ResultSuccess);
193 225 rb.Push(0);
194 rb.Push<u32>(0); // Friend count
195 // TODO(ogniK): Return a buffer of u64s which are the "NetworkServiceAccountId"
196 } 226 }
197 227
198 void CheckFriendListAvailability(HLERequestContext& ctx) { 228 void GetNewlyFriendCount(HLERequestContext& ctx) {
199 IPC::RequestParser rp{ctx}; 229 LOG_DEBUG(Service_Friend, "(STUBBED) called");
200 const auto uuid{rp.PopRaw<Common::UUID>()};
201 230
202 LOG_WARNING(Service_Friend, "(STUBBED) called, uuid=0x{}", uuid.RawString()); 231 IPC::ResponseBuilder rb{ctx, 3};
232 rb.Push(ResultSuccess);
233 rb.Push(0);
234 }
235
236 void GetReceivedFriendRequestCount(HLERequestContext& ctx) {
237 LOG_DEBUG(Service_Friend, "(STUBBED) called");
203 238
204 IPC::ResponseBuilder rb{ctx, 3}; 239 IPC::ResponseBuilder rb{ctx, 3};
205 rb.Push(ResultSuccess); 240 rb.Push(ResultSuccess);
206 rb.Push(true); 241 rb.Push(0);
207 } 242 }
208 243
209 void CheckBlockedUserListAvailability(HLERequestContext& ctx) { 244 void GetPlayHistoryStatistics(HLERequestContext& ctx) {
210 IPC::RequestParser rp{ctx}; 245 LOG_ERROR(Service_Friend, "(STUBBED) called, check in out");
211 const auto uuid{rp.PopRaw<Common::UUID>()};
212 246
213 LOG_WARNING(Service_Friend, "(STUBBED) called, uuid=0x{}", uuid.RawString()); 247 IPC::ResponseBuilder rb{ctx, 2};
248 rb.Push(ResultSuccess);
249 }
250
251 void GetReceivedFriendInvitationCountCache(HLERequestContext& ctx) {
252 LOG_DEBUG(Service_Friend, "(STUBBED) called, check in out");
214 253
215 IPC::ResponseBuilder rb{ctx, 3}; 254 IPC::ResponseBuilder rb{ctx, 3};
216 rb.Push(ResultSuccess); 255 rb.Push(ResultSuccess);
217 rb.Push(true); 256 rb.Push(0);
218 } 257 }
219 258
220 KernelHelpers::ServiceContext service_context; 259 KernelHelpers::ServiceContext service_context;
diff --git a/src/core/hle/service/glue/time/manager.cpp b/src/core/hle/service/glue/time/manager.cpp
index 059ac3fc9..cb88486dd 100644
--- a/src/core/hle/service/glue/time/manager.cpp
+++ b/src/core/hle/service/glue/time/manager.cpp
@@ -51,16 +51,17 @@ s64 CalendarTimeToEpoch(Service::PSC::Time::CalendarTime calendar) {
51} 51}
52 52
53s64 GetEpochTimeFromInitialYear(std::shared_ptr<Service::Set::ISystemSettingsServer>& set_sys) { 53s64 GetEpochTimeFromInitialYear(std::shared_ptr<Service::Set::ISystemSettingsServer>& set_sys) {
54 s32 year{2000};
55 set_sys->GetSettingsItemValueImpl(year, "time", "standard_user_clock_initial_year");
56
54 Service::PSC::Time::CalendarTime calendar{ 57 Service::PSC::Time::CalendarTime calendar{
55 .year = 2000, 58 .year = static_cast<s16>(year),
56 .month = 1, 59 .month = 1,
57 .day = 1, 60 .day = 1,
58 .hour = 0, 61 .hour = 0,
59 .minute = 0, 62 .minute = 0,
60 .second = 0, 63 .second = 0,
61 }; 64 };
62 set_sys->GetSettingsItemValueImpl<s16>(calendar.year, "time",
63 "standard_user_clock_initial_year");
64 return CalendarTimeToEpoch(calendar); 65 return CalendarTimeToEpoch(calendar);
65} 66}
66 67
diff --git a/src/core/hle/service/glue/time/worker.cpp b/src/core/hle/service/glue/time/worker.cpp
index b28569b68..b6bbd7965 100644
--- a/src/core/hle/service/glue/time/worker.cpp
+++ b/src/core/hle/service/glue/time/worker.cpp
@@ -26,12 +26,9 @@ Service::PSC::Time::SystemClockContext g_report_ephemeral_clock_context{};
26template <typename T> 26template <typename T>
27T GetSettingsItemValue(std::shared_ptr<Service::Set::ISystemSettingsServer>& set_sys, 27T GetSettingsItemValue(std::shared_ptr<Service::Set::ISystemSettingsServer>& set_sys,
28 const char* category, const char* name) { 28 const char* category, const char* name) {
29 std::vector<u8> interval_buf;
30 auto res = set_sys->GetSettingsItemValueImpl(interval_buf, category, name);
31 ASSERT(res == ResultSuccess);
32
33 T v{}; 29 T v{};
34 std::memcpy(&v, interval_buf.data(), sizeof(T)); 30 auto res = set_sys->GetSettingsItemValueImpl(v, category, name);
31 ASSERT(res == ResultSuccess);
35 return v; 32 return v;
36} 33}
37 34
diff --git a/src/core/hle/service/hid/hid_system_server.cpp b/src/core/hle/service/hid/hid_system_server.cpp
index 7126a1dcd..b0cd63d72 100644
--- a/src/core/hle/service/hid/hid_system_server.cpp
+++ b/src/core/hle/service/hid/hid_system_server.cpp
@@ -201,7 +201,7 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
201 {1269, nullptr, "DeleteButtonConfigStorageLeft"}, 201 {1269, nullptr, "DeleteButtonConfigStorageLeft"},
202 {1270, nullptr, "DeleteButtonConfigStorageRight"}, 202 {1270, nullptr, "DeleteButtonConfigStorageRight"},
203 {1271, &IHidSystemServer::IsUsingCustomButtonConfig, "IsUsingCustomButtonConfig"}, 203 {1271, &IHidSystemServer::IsUsingCustomButtonConfig, "IsUsingCustomButtonConfig"},
204 {1272, nullptr, "IsAnyCustomButtonConfigEnabled"}, 204 {1272, &IHidSystemServer::IsAnyCustomButtonConfigEnabled, "IsAnyCustomButtonConfigEnabled"},
205 {1273, nullptr, "SetAllCustomButtonConfigEnabled"}, 205 {1273, nullptr, "SetAllCustomButtonConfigEnabled"},
206 {1274, nullptr, "SetDefaultButtonConfig"}, 206 {1274, nullptr, "SetDefaultButtonConfig"},
207 {1275, nullptr, "SetAllDefaultButtonConfig"}, 207 {1275, nullptr, "SetAllDefaultButtonConfig"},
@@ -926,6 +926,16 @@ void IHidSystemServer::IsUsingCustomButtonConfig(HLERequestContext& ctx) {
926 rb.Push(is_enabled); 926 rb.Push(is_enabled);
927} 927}
928 928
929void IHidSystemServer::IsAnyCustomButtonConfigEnabled(HLERequestContext& ctx) {
930 const bool is_enabled = false;
931
932 LOG_DEBUG(Service_HID, "(STUBBED) called, is_enabled={}", is_enabled);
933
934 IPC::ResponseBuilder rb{ctx, 3};
935 rb.Push(ResultSuccess);
936 rb.Push(is_enabled);
937}
938
929std::shared_ptr<ResourceManager> IHidSystemServer::GetResourceManager() { 939std::shared_ptr<ResourceManager> IHidSystemServer::GetResourceManager() {
930 resource_manager->Initialize(); 940 resource_manager->Initialize();
931 return resource_manager; 941 return resource_manager;
diff --git a/src/core/hle/service/hid/hid_system_server.h b/src/core/hle/service/hid/hid_system_server.h
index 738313e08..1a4f244d7 100644
--- a/src/core/hle/service/hid/hid_system_server.h
+++ b/src/core/hle/service/hid/hid_system_server.h
@@ -77,6 +77,7 @@ private:
77 void GetTouchScreenDefaultConfiguration(HLERequestContext& ctx); 77 void GetTouchScreenDefaultConfiguration(HLERequestContext& ctx);
78 void SetForceHandheldStyleVibration(HLERequestContext& ctx); 78 void SetForceHandheldStyleVibration(HLERequestContext& ctx);
79 void IsUsingCustomButtonConfig(HLERequestContext& ctx); 79 void IsUsingCustomButtonConfig(HLERequestContext& ctx);
80 void IsAnyCustomButtonConfigEnabled(HLERequestContext& ctx);
80 81
81 std::shared_ptr<ResourceManager> GetResourceManager(); 82 std::shared_ptr<ResourceManager> GetResourceManager();
82 83
diff --git a/src/core/hle/service/lbl/lbl.cpp b/src/core/hle/service/lbl/lbl.cpp
index 98a79365d..c14b24142 100644
--- a/src/core/hle/service/lbl/lbl.cpp
+++ b/src/core/hle/service/lbl/lbl.cpp
@@ -18,8 +18,8 @@ public:
18 explicit LBL(Core::System& system_) : ServiceFramework{system_, "lbl"} { 18 explicit LBL(Core::System& system_) : ServiceFramework{system_, "lbl"} {
19 // clang-format off 19 // clang-format off
20 static const FunctionInfo functions[] = { 20 static const FunctionInfo functions[] = {
21 {0, nullptr, "SaveCurrentSetting"}, 21 {0, &LBL::SaveCurrentSetting, "SaveCurrentSetting"},
22 {1, nullptr, "LoadCurrentSetting"}, 22 {1, &LBL::LoadCurrentSetting, "LoadCurrentSetting"},
23 {2, &LBL::SetCurrentBrightnessSetting, "SetCurrentBrightnessSetting"}, 23 {2, &LBL::SetCurrentBrightnessSetting, "SetCurrentBrightnessSetting"},
24 {3, &LBL::GetCurrentBrightnessSetting, "GetCurrentBrightnessSetting"}, 24 {3, &LBL::GetCurrentBrightnessSetting, "GetCurrentBrightnessSetting"},
25 {4, nullptr, "ApplyCurrentBrightnessSettingToBacklight"}, 25 {4, nullptr, "ApplyCurrentBrightnessSettingToBacklight"},
@@ -47,7 +47,7 @@ public:
47 {26, &LBL::EnableVrMode, "EnableVrMode"}, 47 {26, &LBL::EnableVrMode, "EnableVrMode"},
48 {27, &LBL::DisableVrMode, "DisableVrMode"}, 48 {27, &LBL::DisableVrMode, "DisableVrMode"},
49 {28, &LBL::IsVrModeEnabled, "IsVrModeEnabled"}, 49 {28, &LBL::IsVrModeEnabled, "IsVrModeEnabled"},
50 {29, nullptr, "IsAutoBrightnessControlSupported"}, 50 {29, &LBL::IsAutoBrightnessControlSupported, "IsAutoBrightnessControlSupported"},
51 }; 51 };
52 // clang-format on 52 // clang-format on
53 53
@@ -60,6 +60,20 @@ private:
60 On = 1, 60 On = 1,
61 }; 61 };
62 62
63 void SaveCurrentSetting(HLERequestContext& ctx) {
64 LOG_WARNING(Service_LBL, "(STUBBED) called");
65
66 IPC::ResponseBuilder rb{ctx, 2};
67 rb.Push(ResultSuccess);
68 }
69
70 void LoadCurrentSetting(HLERequestContext& ctx) {
71 LOG_WARNING(Service_LBL, "(STUBBED) called");
72
73 IPC::ResponseBuilder rb{ctx, 2};
74 rb.Push(ResultSuccess);
75 }
76
63 void SetCurrentBrightnessSetting(HLERequestContext& ctx) { 77 void SetCurrentBrightnessSetting(HLERequestContext& ctx) {
64 IPC::RequestParser rp{ctx}; 78 IPC::RequestParser rp{ctx};
65 auto brightness = rp.Pop<float>(); 79 auto brightness = rp.Pop<float>();
@@ -310,6 +324,14 @@ private:
310 rb.Push(vr_mode_enabled); 324 rb.Push(vr_mode_enabled);
311 } 325 }
312 326
327 void IsAutoBrightnessControlSupported(HLERequestContext& ctx) {
328 LOG_DEBUG(Service_LBL, "called");
329
330 IPC::ResponseBuilder rb{ctx, 3};
331 rb.Push(ResultSuccess);
332 rb.Push<u8>(auto_brightness_supported);
333 }
334
313 bool vr_mode_enabled = false; 335 bool vr_mode_enabled = false;
314 float current_brightness = 1.0f; 336 float current_brightness = 1.0f;
315 float ambient_light_value = 0.0f; 337 float ambient_light_value = 0.0f;
@@ -317,7 +339,8 @@ private:
317 bool dimming = true; 339 bool dimming = true;
318 bool backlight_enabled = true; 340 bool backlight_enabled = true;
319 bool update_instantly = false; 341 bool update_instantly = false;
320 bool auto_brightness = false; // TODO(ogniK): Move to system settings 342 bool auto_brightness = false;
343 bool auto_brightness_supported = true; // TODO(ogniK): Move to system settings
321}; 344};
322 345
323void LoopProcess(Core::System& system) { 346void LoopProcess(Core::System& system) {
diff --git a/src/core/hle/service/ldn/monitor_service.cpp b/src/core/hle/service/ldn/monitor_service.cpp
index 3471f69da..ea6ac4d5d 100644
--- a/src/core/hle/service/ldn/monitor_service.cpp
+++ b/src/core/hle/service/ldn/monitor_service.cpp
@@ -2,6 +2,7 @@
2// SPDX-License-Identifier: GPL-3.0-or-later 2// SPDX-License-Identifier: GPL-3.0-or-later
3 3
4#include "core/hle/service/cmif_serialization.h" 4#include "core/hle/service/cmif_serialization.h"
5#include "core/hle/service/ldn/ldn_results.h"
5#include "core/hle/service/ldn/monitor_service.h" 6#include "core/hle/service/ldn/monitor_service.h"
6 7
7namespace Service::LDN { 8namespace Service::LDN {
@@ -17,7 +18,7 @@ IMonitorService::IMonitorService(Core::System& system_)
17 {4, nullptr, "GetSecurityParameterForMonitor"}, 18 {4, nullptr, "GetSecurityParameterForMonitor"},
18 {5, nullptr, "GetNetworkConfigForMonitor"}, 19 {5, nullptr, "GetNetworkConfigForMonitor"},
19 {100, C<&IMonitorService::InitializeMonitor>, "InitializeMonitor"}, 20 {100, C<&IMonitorService::InitializeMonitor>, "InitializeMonitor"},
20 {101, nullptr, "FinalizeMonitor"}, 21 {101, C<&IMonitorService::FinalizeMonitor>, "FinalizeMonitor"},
21 }; 22 };
22 // clang-format on 23 // clang-format on
23 24
@@ -27,16 +28,18 @@ IMonitorService::IMonitorService(Core::System& system_)
27IMonitorService::~IMonitorService() = default; 28IMonitorService::~IMonitorService() = default;
28 29
29Result IMonitorService::GetStateForMonitor(Out<State> out_state) { 30Result IMonitorService::GetStateForMonitor(Out<State> out_state) {
30 LOG_INFO(Service_LDN, "called"); 31 LOG_WARNING(Service_LDN, "(STUBBED) called");
31 32 *out_state = State::None;
32 *out_state = state;
33 R_SUCCEED(); 33 R_SUCCEED();
34} 34}
35 35
36Result IMonitorService::InitializeMonitor() { 36Result IMonitorService::InitializeMonitor() {
37 LOG_INFO(Service_LDN, "called"); 37 LOG_INFO(Service_LDN, "called");
38 R_SUCCEED();
39}
38 40
39 state = State::Initialized; 41Result IMonitorService::FinalizeMonitor() {
42 LOG_INFO(Service_LDN, "called");
40 R_SUCCEED(); 43 R_SUCCEED();
41} 44}
42 45
diff --git a/src/core/hle/service/ldn/monitor_service.h b/src/core/hle/service/ldn/monitor_service.h
index 61aacef30..e663145b4 100644
--- a/src/core/hle/service/ldn/monitor_service.h
+++ b/src/core/hle/service/ldn/monitor_service.h
@@ -21,6 +21,7 @@ public:
21private: 21private:
22 Result GetStateForMonitor(Out<State> out_state); 22 Result GetStateForMonitor(Out<State> out_state);
23 Result InitializeMonitor(); 23 Result InitializeMonitor();
24 Result FinalizeMonitor();
24 25
25 State state{State::None}; 26 State state{State::None};
26}; 27};
diff --git a/src/core/hle/service/nfc/common/device_manager.cpp b/src/core/hle/service/nfc/common/device_manager.cpp
index 94a8243b5..2dd3e9f89 100644
--- a/src/core/hle/service/nfc/common/device_manager.cpp
+++ b/src/core/hle/service/nfc/common/device_manager.cpp
@@ -13,6 +13,7 @@
13#include "core/hle/service/nfc/nfc_result.h" 13#include "core/hle/service/nfc/nfc_result.h"
14#include "core/hle/service/psc/time/steady_clock.h" 14#include "core/hle/service/psc/time/steady_clock.h"
15#include "core/hle/service/service.h" 15#include "core/hle/service/service.h"
16#include "core/hle/service/set/system_settings_server.h"
16#include "core/hle/service/sm/sm.h" 17#include "core/hle/service/sm/sm.h"
17#include "hid_core/hid_types.h" 18#include "hid_core/hid_types.h"
18#include "hid_core/hid_util.h" 19#include "hid_core/hid_util.h"
@@ -32,6 +33,9 @@ DeviceManager::DeviceManager(Core::System& system_, KernelHelpers::ServiceContex
32 } 33 }
33 34
34 is_initialized = false; 35 is_initialized = false;
36
37 m_set_sys =
38 system.ServiceManager().GetService<Service::Set::ISystemSettingsServer>("set:sys", true);
35} 39}
36 40
37DeviceManager ::~DeviceManager() { 41DeviceManager ::~DeviceManager() {
@@ -774,8 +778,8 @@ Result DeviceManager::CheckDeviceState(std::shared_ptr<NfcDevice> device) const
774} 778}
775 779
776Result DeviceManager::IsNfcEnabled() const { 780Result DeviceManager::IsNfcEnabled() const {
777 // TODO: This calls nn::settings::detail::GetNfcEnableFlag 781 bool is_enabled{};
778 const bool is_enabled = true; 782 R_TRY(m_set_sys->GetNfcEnableFlag(&is_enabled));
779 if (!is_enabled) { 783 if (!is_enabled) {
780 return ResultNfcDisabled; 784 return ResultNfcDisabled;
781 } 785 }
diff --git a/src/core/hle/service/nfc/common/device_manager.h b/src/core/hle/service/nfc/common/device_manager.h
index c56a2fbda..6c0e6b255 100644
--- a/src/core/hle/service/nfc/common/device_manager.h
+++ b/src/core/hle/service/nfc/common/device_manager.h
@@ -15,6 +15,10 @@
15#include "core/hle/service/service.h" 15#include "core/hle/service/service.h"
16#include "hid_core/hid_types.h" 16#include "hid_core/hid_types.h"
17 17
18namespace Service::Set {
19class ISystemSettingsServer;
20}
21
18namespace Service::NFC { 22namespace Service::NFC {
19class NfcDevice; 23class NfcDevice;
20 24
@@ -98,6 +102,7 @@ private:
98 Core::System& system; 102 Core::System& system;
99 KernelHelpers::ServiceContext service_context; 103 KernelHelpers::ServiceContext service_context;
100 Kernel::KEvent* availability_change_event; 104 Kernel::KEvent* availability_change_event;
105 std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys;
101}; 106};
102 107
103} // namespace Service::NFC 108} // namespace Service::NFC
diff --git a/src/core/hle/service/nfc/nfc.cpp b/src/core/hle/service/nfc/nfc.cpp
index 30ae989b9..9d4808dbe 100644
--- a/src/core/hle/service/nfc/nfc.cpp
+++ b/src/core/hle/service/nfc/nfc.cpp
@@ -57,7 +57,7 @@ public:
57 {1, &NfcInterface::Finalize, "FinalizeOld"}, 57 {1, &NfcInterface::Finalize, "FinalizeOld"},
58 {2, &NfcInterface::GetState, "GetStateOld"}, 58 {2, &NfcInterface::GetState, "GetStateOld"},
59 {3, &NfcInterface::IsNfcEnabled, "IsNfcEnabledOld"}, 59 {3, &NfcInterface::IsNfcEnabled, "IsNfcEnabledOld"},
60 {100, nullptr, "SetNfcEnabledOld"}, 60 {100, &NfcInterface::SetNfcEnabled, "SetNfcEnabledOld"},
61 {400, &NfcInterface::Initialize, "Initialize"}, 61 {400, &NfcInterface::Initialize, "Initialize"},
62 {401, &NfcInterface::Finalize, "Finalize"}, 62 {401, &NfcInterface::Finalize, "Finalize"},
63 {402, &NfcInterface::GetState, "GetState"}, 63 {402, &NfcInterface::GetState, "GetState"},
@@ -71,7 +71,7 @@ public:
71 {410, &NfcInterface::GetTagInfo, "GetTagInfo"}, 71 {410, &NfcInterface::GetTagInfo, "GetTagInfo"},
72 {411, &NfcInterface::AttachActivateEvent, "AttachActivateEvent"}, 72 {411, &NfcInterface::AttachActivateEvent, "AttachActivateEvent"},
73 {412, &NfcInterface::AttachDeactivateEvent, "AttachDeactivateEvent"}, 73 {412, &NfcInterface::AttachDeactivateEvent, "AttachDeactivateEvent"},
74 {500, nullptr, "SetNfcEnabled"}, 74 {500, &NfcInterface::SetNfcEnabled, "SetNfcEnabled"},
75 {510, nullptr, "OutputTestWave"}, 75 {510, nullptr, "OutputTestWave"},
76 {1000, &NfcInterface::ReadMifare, "ReadMifare"}, 76 {1000, &NfcInterface::ReadMifare, "ReadMifare"},
77 {1001, &NfcInterface::WriteMifare, "WriteMifare"}, 77 {1001, &NfcInterface::WriteMifare, "WriteMifare"},
diff --git a/src/core/hle/service/nfc/nfc_interface.cpp b/src/core/hle/service/nfc/nfc_interface.cpp
index 3e2c7deab..c28e55431 100644
--- a/src/core/hle/service/nfc/nfc_interface.cpp
+++ b/src/core/hle/service/nfc/nfc_interface.cpp
@@ -13,13 +13,18 @@
13#include "core/hle/service/nfc/nfc_result.h" 13#include "core/hle/service/nfc/nfc_result.h"
14#include "core/hle/service/nfc/nfc_types.h" 14#include "core/hle/service/nfc/nfc_types.h"
15#include "core/hle/service/nfp/nfp_result.h" 15#include "core/hle/service/nfp/nfp_result.h"
16#include "core/hle/service/set/system_settings_server.h"
17#include "core/hle/service/sm/sm.h"
16#include "hid_core/hid_types.h" 18#include "hid_core/hid_types.h"
17 19
18namespace Service::NFC { 20namespace Service::NFC {
19 21
20NfcInterface::NfcInterface(Core::System& system_, const char* name, BackendType service_backend) 22NfcInterface::NfcInterface(Core::System& system_, const char* name, BackendType service_backend)
21 : ServiceFramework{system_, name}, service_context{system_, service_name}, 23 : ServiceFramework{system_, name}, service_context{system_, service_name},
22 backend_type{service_backend} {} 24 backend_type{service_backend} {
25 m_set_sys =
26 system.ServiceManager().GetService<Service::Set::ISystemSettingsServer>("set:sys", true);
27}
23 28
24NfcInterface ::~NfcInterface() = default; 29NfcInterface ::~NfcInterface() = default;
25 30
@@ -65,11 +70,11 @@ void NfcInterface::GetState(HLERequestContext& ctx) {
65void NfcInterface::IsNfcEnabled(HLERequestContext& ctx) { 70void NfcInterface::IsNfcEnabled(HLERequestContext& ctx) {
66 LOG_DEBUG(Service_NFC, "called"); 71 LOG_DEBUG(Service_NFC, "called");
67 72
68 // TODO: This calls nn::settings::detail::GetNfcEnableFlag 73 bool is_enabled{};
69 const bool is_enabled = true; 74 const auto result = m_set_sys->GetNfcEnableFlag(&is_enabled);
70 75
71 IPC::ResponseBuilder rb{ctx, 3}; 76 IPC::ResponseBuilder rb{ctx, 3};
72 rb.Push(ResultSuccess); 77 rb.Push(result);
73 rb.Push(is_enabled); 78 rb.Push(is_enabled);
74} 79}
75 80
@@ -212,6 +217,17 @@ void NfcInterface::AttachDeactivateEvent(HLERequestContext& ctx) {
212 rb.PushCopyObjects(out_event); 217 rb.PushCopyObjects(out_event);
213} 218}
214 219
220void NfcInterface::SetNfcEnabled(HLERequestContext& ctx) {
221 IPC::RequestParser rp{ctx};
222 const auto is_enabled{rp.Pop<bool>()};
223 LOG_DEBUG(Service_NFC, "called, is_enabled={}", is_enabled);
224
225 const auto result = m_set_sys->SetNfcEnableFlag(is_enabled);
226
227 IPC::ResponseBuilder rb{ctx, 2};
228 rb.Push(result);
229}
230
215void NfcInterface::ReadMifare(HLERequestContext& ctx) { 231void NfcInterface::ReadMifare(HLERequestContext& ctx) {
216 IPC::RequestParser rp{ctx}; 232 IPC::RequestParser rp{ctx};
217 const auto device_handle{rp.Pop<u64>()}; 233 const auto device_handle{rp.Pop<u64>()};
diff --git a/src/core/hle/service/nfc/nfc_interface.h b/src/core/hle/service/nfc/nfc_interface.h
index 08be174d8..5cc0d8ec0 100644
--- a/src/core/hle/service/nfc/nfc_interface.h
+++ b/src/core/hle/service/nfc/nfc_interface.h
@@ -7,6 +7,10 @@
7#include "core/hle/service/nfc/nfc_types.h" 7#include "core/hle/service/nfc/nfc_types.h"
8#include "core/hle/service/service.h" 8#include "core/hle/service/service.h"
9 9
10namespace Service::Set {
11class ISystemSettingsServer;
12}
13
10namespace Service::NFC { 14namespace Service::NFC {
11class DeviceManager; 15class DeviceManager;
12 16
@@ -29,6 +33,7 @@ public:
29 void AttachActivateEvent(HLERequestContext& ctx); 33 void AttachActivateEvent(HLERequestContext& ctx);
30 void AttachDeactivateEvent(HLERequestContext& ctx); 34 void AttachDeactivateEvent(HLERequestContext& ctx);
31 void ReadMifare(HLERequestContext& ctx); 35 void ReadMifare(HLERequestContext& ctx);
36 void SetNfcEnabled(HLERequestContext& ctx);
32 void WriteMifare(HLERequestContext& ctx); 37 void WriteMifare(HLERequestContext& ctx);
33 void SendCommandByPassThrough(HLERequestContext& ctx); 38 void SendCommandByPassThrough(HLERequestContext& ctx);
34 39
@@ -44,6 +49,7 @@ protected:
44 BackendType backend_type; 49 BackendType backend_type;
45 State state{State::NonInitialized}; 50 State state{State::NonInitialized};
46 std::shared_ptr<DeviceManager> device_manager = nullptr; 51 std::shared_ptr<DeviceManager> device_manager = nullptr;
52 std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys;
47}; 53};
48 54
49} // namespace Service::NFC 55} // namespace Service::NFC
diff --git a/src/core/hle/service/npns/npns.cpp b/src/core/hle/service/npns/npns.cpp
index a162e5c54..e54827efe 100644
--- a/src/core/hle/service/npns/npns.cpp
+++ b/src/core/hle/service/npns/npns.cpp
@@ -3,22 +3,26 @@
3 3
4#include <memory> 4#include <memory>
5 5
6#include "core/hle/kernel/k_event.h"
7#include "core/hle/service/cmif_serialization.h"
8#include "core/hle/service/kernel_helpers.h"
6#include "core/hle/service/npns/npns.h" 9#include "core/hle/service/npns/npns.h"
7#include "core/hle/service/server_manager.h" 10#include "core/hle/service/server_manager.h"
8#include "core/hle/service/service.h" 11#include "core/hle/service/service.h"
9 12
10namespace Service::NPNS { 13namespace Service::NPNS {
11 14
12class NPNS_S final : public ServiceFramework<NPNS_S> { 15class INpnsSystem final : public ServiceFramework<INpnsSystem> {
13public: 16public:
14 explicit NPNS_S(Core::System& system_) : ServiceFramework{system_, "npns:s"} { 17 explicit INpnsSystem(Core::System& system_)
18 : ServiceFramework{system_, "npns:s"}, service_context{system, "npns:s"} {
15 // clang-format off 19 // clang-format off
16 static const FunctionInfo functions[] = { 20 static const FunctionInfo functions[] = {
17 {1, nullptr, "ListenAll"}, 21 {1, nullptr, "ListenAll"},
18 {2, nullptr, "ListenTo"}, 22 {2, C<&INpnsSystem::ListenTo>, "ListenTo"},
19 {3, nullptr, "Receive"}, 23 {3, nullptr, "Receive"},
20 {4, nullptr, "ReceiveRaw"}, 24 {4, nullptr, "ReceiveRaw"},
21 {5, nullptr, "GetReceiveEvent"}, 25 {5, C<&INpnsSystem::GetReceiveEvent>, "GetReceiveEvent"},
22 {6, nullptr, "ListenUndelivered"}, 26 {6, nullptr, "ListenUndelivered"},
23 {7, nullptr, "GetStateChangeEVent"}, 27 {7, nullptr, "GetStateChangeEVent"},
24 {11, nullptr, "SubscribeTopic"}, 28 {11, nullptr, "SubscribeTopic"},
@@ -59,12 +63,34 @@ public:
59 // clang-format on 63 // clang-format on
60 64
61 RegisterHandlers(functions); 65 RegisterHandlers(functions);
66
67 get_receive_event = service_context.CreateEvent("npns:s:GetReceiveEvent");
62 } 68 }
69
70 ~INpnsSystem() override {
71 service_context.CloseEvent(get_receive_event);
72 }
73
74private:
75 Result ListenTo(u32 program_id) {
76 LOG_WARNING(Service_AM, "(STUBBED) called, program_id={}", program_id);
77 R_SUCCEED();
78 }
79
80 Result GetReceiveEvent(OutCopyHandle<Kernel::KReadableEvent> out_event) {
81 LOG_WARNING(Service_AM, "(STUBBED) called");
82
83 *out_event = &get_receive_event->GetReadableEvent();
84 R_SUCCEED();
85 }
86
87 KernelHelpers::ServiceContext service_context;
88 Kernel::KEvent* get_receive_event;
63}; 89};
64 90
65class NPNS_U final : public ServiceFramework<NPNS_U> { 91class INpnsUser final : public ServiceFramework<INpnsUser> {
66public: 92public:
67 explicit NPNS_U(Core::System& system_) : ServiceFramework{system_, "npns:u"} { 93 explicit INpnsUser(Core::System& system_) : ServiceFramework{system_, "npns:u"} {
68 // clang-format off 94 // clang-format off
69 static const FunctionInfo functions[] = { 95 static const FunctionInfo functions[] = {
70 {1, nullptr, "ListenAll"}, 96 {1, nullptr, "ListenAll"},
@@ -97,8 +123,8 @@ public:
97void LoopProcess(Core::System& system) { 123void LoopProcess(Core::System& system) {
98 auto server_manager = std::make_unique<ServerManager>(system); 124 auto server_manager = std::make_unique<ServerManager>(system);
99 125
100 server_manager->RegisterNamedService("npns:s", std::make_shared<NPNS_S>(system)); 126 server_manager->RegisterNamedService("npns:s", std::make_shared<INpnsSystem>(system));
101 server_manager->RegisterNamedService("npns:u", std::make_shared<NPNS_U>(system)); 127 server_manager->RegisterNamedService("npns:u", std::make_shared<INpnsUser>(system));
102 ServerManager::RunServer(std::move(server_manager)); 128 ServerManager::RunServer(std::move(server_manager));
103} 129}
104 130
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
index bf12d69a5..efc9cca1c 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
@@ -5,6 +5,7 @@
5#include "common/assert.h" 5#include "common/assert.h"
6#include "common/logging/log.h" 6#include "common/logging/log.h"
7#include "core/core.h" 7#include "core/core.h"
8#include "core/hle/kernel/k_process.h"
8#include "core/hle/service/nvdrv/core/container.h" 9#include "core/hle/service/nvdrv/core/container.h"
9#include "core/hle/service/nvdrv/core/nvmap.h" 10#include "core/hle/service/nvdrv/core/nvmap.h"
10#include "core/hle/service/nvdrv/core/syncpoint_manager.h" 11#include "core/hle/service/nvdrv/core/syncpoint_manager.h"
@@ -75,7 +76,7 @@ NvResult nvhost_gpu::Ioctl1(DeviceFD fd, Ioctl command, std::span<const u8> inpu
75 case 0xd: 76 case 0xd:
76 return WrapFixed(this, &nvhost_gpu::SetChannelPriority, input, output); 77 return WrapFixed(this, &nvhost_gpu::SetChannelPriority, input, output);
77 case 0x1a: 78 case 0x1a:
78 return WrapFixed(this, &nvhost_gpu::AllocGPFIFOEx2, input, output); 79 return WrapFixed(this, &nvhost_gpu::AllocGPFIFOEx2, input, output, fd);
79 case 0x1b: 80 case 0x1b:
80 return WrapFixedVariable(this, &nvhost_gpu::SubmitGPFIFOBase1, input, output, true); 81 return WrapFixedVariable(this, &nvhost_gpu::SubmitGPFIFOBase1, input, output, true);
81 case 0x1d: 82 case 0x1d:
@@ -120,8 +121,13 @@ NvResult nvhost_gpu::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> inpu
120 return NvResult::NotImplemented; 121 return NvResult::NotImplemented;
121} 122}
122 123
123void nvhost_gpu::OnOpen(NvCore::SessionId session_id, DeviceFD fd) {} 124void nvhost_gpu::OnOpen(NvCore::SessionId session_id, DeviceFD fd) {
124void nvhost_gpu::OnClose(DeviceFD fd) {} 125 sessions[fd] = session_id;
126}
127
128void nvhost_gpu::OnClose(DeviceFD fd) {
129 sessions.erase(fd);
130}
125 131
126NvResult nvhost_gpu::SetNVMAPfd(IoctlSetNvmapFD& params) { 132NvResult nvhost_gpu::SetNVMAPfd(IoctlSetNvmapFD& params) {
127 LOG_DEBUG(Service_NVDRV, "called, fd={}", params.nvmap_fd); 133 LOG_DEBUG(Service_NVDRV, "called, fd={}", params.nvmap_fd);
@@ -161,7 +167,7 @@ NvResult nvhost_gpu::SetChannelPriority(IoctlChannelSetPriority& params) {
161 return NvResult::Success; 167 return NvResult::Success;
162} 168}
163 169
164NvResult nvhost_gpu::AllocGPFIFOEx2(IoctlAllocGpfifoEx2& params) { 170NvResult nvhost_gpu::AllocGPFIFOEx2(IoctlAllocGpfifoEx2& params, DeviceFD fd) {
165 LOG_WARNING(Service_NVDRV, 171 LOG_WARNING(Service_NVDRV,
166 "(STUBBED) called, num_entries={:X}, flags={:X}, unk0={:X}, " 172 "(STUBBED) called, num_entries={:X}, flags={:X}, unk0={:X}, "
167 "unk1={:X}, unk2={:X}, unk3={:X}", 173 "unk1={:X}, unk2={:X}, unk3={:X}",
@@ -173,7 +179,12 @@ NvResult nvhost_gpu::AllocGPFIFOEx2(IoctlAllocGpfifoEx2& params) {
173 return NvResult::AlreadyAllocated; 179 return NvResult::AlreadyAllocated;
174 } 180 }
175 181
176 system.GPU().InitChannel(*channel_state); 182 u64 program_id{};
183 if (auto* const session = core.GetSession(sessions[fd]); session != nullptr) {
184 program_id = session->process->GetProgramId();
185 }
186
187 system.GPU().InitChannel(*channel_state, program_id);
177 188
178 params.fence_out = syncpoint_manager.GetSyncpointFence(channel_syncpoint); 189 params.fence_out = syncpoint_manager.GetSyncpointFence(channel_syncpoint);
179 190
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h
index e34a978db..e0aeef953 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h
@@ -192,7 +192,7 @@ private:
192 NvResult ZCullBind(IoctlZCullBind& params); 192 NvResult ZCullBind(IoctlZCullBind& params);
193 NvResult SetErrorNotifier(IoctlSetErrorNotifier& params); 193 NvResult SetErrorNotifier(IoctlSetErrorNotifier& params);
194 NvResult SetChannelPriority(IoctlChannelSetPriority& params); 194 NvResult SetChannelPriority(IoctlChannelSetPriority& params);
195 NvResult AllocGPFIFOEx2(IoctlAllocGpfifoEx2& params); 195 NvResult AllocGPFIFOEx2(IoctlAllocGpfifoEx2& params, DeviceFD fd);
196 NvResult AllocateObjectContext(IoctlAllocObjCtx& params); 196 NvResult AllocateObjectContext(IoctlAllocObjCtx& params);
197 197
198 NvResult SubmitGPFIFOImpl(IoctlSubmitGpfifo& params, Tegra::CommandList&& entries); 198 NvResult SubmitGPFIFOImpl(IoctlSubmitGpfifo& params, Tegra::CommandList&& entries);
@@ -210,6 +210,7 @@ private:
210 NvCore::SyncpointManager& syncpoint_manager; 210 NvCore::SyncpointManager& syncpoint_manager;
211 NvCore::NvMap& nvmap; 211 NvCore::NvMap& nvmap;
212 std::shared_ptr<Tegra::Control::ChannelState> channel_state; 212 std::shared_ptr<Tegra::Control::ChannelState> channel_state;
213 std::unordered_map<DeviceFD, NvCore::SessionId> sessions;
213 u32 channel_syncpoint; 214 u32 channel_syncpoint;
214 std::mutex channel_mutex; 215 std::mutex channel_mutex;
215 216
diff --git a/src/core/hle/service/server_manager.cpp b/src/core/hle/service/server_manager.cpp
index 0b41bbcb9..3d898725e 100644
--- a/src/core/hle/service/server_manager.cpp
+++ b/src/core/hle/service/server_manager.cpp
@@ -93,13 +93,19 @@ ServerManager::~ServerManager() {
93 m_threads.clear(); 93 m_threads.clear();
94 94
95 // Clean up ports. 95 // Clean up ports.
96 for (auto it = m_servers.begin(); it != m_servers.end(); it = m_servers.erase(it)) { 96 auto port_it = m_servers.begin();
97 delete std::addressof(*it); 97 while (port_it != m_servers.end()) {
98 auto* const port = std::addressof(*port_it);
99 port_it = m_servers.erase(port_it);
100 delete port;
98 } 101 }
99 102
100 // Clean up sessions. 103 // Clean up sessions.
101 for (auto it = m_sessions.begin(); it != m_sessions.end(); it = m_sessions.erase(it)) { 104 auto session_it = m_sessions.begin();
102 delete std::addressof(*it); 105 while (session_it != m_sessions.end()) {
106 auto* const session = std::addressof(*session_it);
107 session_it = m_sessions.erase(session_it);
108 delete session;
103 } 109 }
104 110
105 // Close wakeup event. 111 // Close wakeup event.
diff --git a/src/core/hle/service/services.cpp b/src/core/hle/service/services.cpp
index 1aa85ea54..3defa4b31 100644
--- a/src/core/hle/service/services.cpp
+++ b/src/core/hle/service/services.cpp
@@ -5,7 +5,7 @@
5 5
6#include "core/hle/service/acc/acc.h" 6#include "core/hle/service/acc/acc.h"
7#include "core/hle/service/am/am.h" 7#include "core/hle/service/am/am.h"
8#include "core/hle/service/aoc/aoc_u.h" 8#include "core/hle/service/aoc/addon_content_manager.h"
9#include "core/hle/service/apm/apm.h" 9#include "core/hle/service/apm/apm.h"
10#include "core/hle/service/audio/audio.h" 10#include "core/hle/service/audio/audio.h"
11#include "core/hle/service/bcat/bcat.h" 11#include "core/hle/service/bcat/bcat.h"
diff --git a/src/core/hle/service/set/setting_formats/system_settings.cpp b/src/core/hle/service/set/setting_formats/system_settings.cpp
index 7231ff78e..caa30c2d5 100644
--- a/src/core/hle/service/set/setting_formats/system_settings.cpp
+++ b/src/core/hle/service/set/setting_formats/system_settings.cpp
@@ -52,6 +52,10 @@ SystemSettings DefaultSystemSettings() {
52 settings.battery_percentage_flag = true; 52 settings.battery_percentage_flag = true;
53 settings.chinese_traditional_input_method = ChineseTraditionalInputMethod::Unknown0; 53 settings.chinese_traditional_input_method = ChineseTraditionalInputMethod::Unknown0;
54 settings.vibration_master_volume = 1.0f; 54 settings.vibration_master_volume = 1.0f;
55 settings.touch_screen_mode = TouchScreenMode::Standard;
56 settings.nfc_enable_flag = true;
57 settings.bluetooth_enable_flag = true;
58 settings.wireless_lan_enable_flag = true;
55 59
56 const auto language_code = 60 const auto language_code =
57 available_language_codes[static_cast<s32>(::Settings::values.language_index.GetValue())]; 61 available_language_codes[static_cast<s32>(::Settings::values.language_index.GetValue())];
diff --git a/src/core/hle/service/set/settings_types.h b/src/core/hle/service/set/settings_types.h
index 29664e88c..92c2948b0 100644
--- a/src/core/hle/service/set/settings_types.h
+++ b/src/core/hle/service/set/settings_types.h
@@ -243,6 +243,11 @@ enum class TvResolution : u32 {
243 Resolution480p, 243 Resolution480p,
244}; 244};
245 245
246enum class PlatformRegion : s32 {
247 Global = 1,
248 Terra = 2,
249};
250
246constexpr std::array<LanguageCode, 18> available_language_codes = {{ 251constexpr std::array<LanguageCode, 18> available_language_codes = {{
247 LanguageCode::JA, 252 LanguageCode::JA,
248 LanguageCode::EN_US, 253 LanguageCode::EN_US,
@@ -405,8 +410,7 @@ struct EulaVersion {
405 SystemRegionCode region_code; 410 SystemRegionCode region_code;
406 EulaVersionClockType clock_type; 411 EulaVersionClockType clock_type;
407 INSERT_PADDING_BYTES(0x4); 412 INSERT_PADDING_BYTES(0x4);
408 s64 posix_time; 413 Service::PSC::Time::SystemClockContext system_clock_context;
409 Service::PSC::Time::SteadyClockTimePoint timestamp;
410}; 414};
411static_assert(sizeof(EulaVersion) == 0x30, "EulaVersion is incorrect size"); 415static_assert(sizeof(EulaVersion) == 0x30, "EulaVersion is incorrect size");
412 416
diff --git a/src/core/hle/service/set/system_settings_server.cpp b/src/core/hle/service/set/system_settings_server.cpp
index 93925f783..0dc8db821 100644
--- a/src/core/hle/service/set/system_settings_server.cpp
+++ b/src/core/hle/service/set/system_settings_server.cpp
@@ -26,7 +26,7 @@
26namespace Service::Set { 26namespace Service::Set {
27 27
28namespace { 28namespace {
29constexpr u32 SETTINGS_VERSION{3u}; 29constexpr u32 SETTINGS_VERSION{4u};
30constexpr auto SETTINGS_MAGIC = Common::MakeMagic('y', 'u', 'z', 'u', '_', 's', 'e', 't'); 30constexpr auto SETTINGS_MAGIC = Common::MakeMagic('y', 'u', 'z', 'u', '_', 's', 'e', 't');
31struct SettingsHeader { 31struct SettingsHeader {
32 u64 magic; 32 u64 magic;
@@ -272,8 +272,8 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_)
272 {180, nullptr, "SetZoomFlag"}, 272 {180, nullptr, "SetZoomFlag"},
273 {181, nullptr, "GetT"}, 273 {181, nullptr, "GetT"},
274 {182, nullptr, "SetT"}, 274 {182, nullptr, "SetT"},
275 {183, nullptr, "GetPlatformRegion"}, 275 {183, C<&ISystemSettingsServer::GetPlatformRegion>, "GetPlatformRegion"},
276 {184, nullptr, "SetPlatformRegion"}, 276 {184, C<&ISystemSettingsServer::SetPlatformRegion>, "SetPlatformRegion"},
277 {185, C<&ISystemSettingsServer::GetHomeMenuSchemeModel>, "GetHomeMenuSchemeModel"}, 277 {185, C<&ISystemSettingsServer::GetHomeMenuSchemeModel>, "GetHomeMenuSchemeModel"},
278 {186, nullptr, "GetMemoryUsageRateFlag"}, 278 {186, nullptr, "GetMemoryUsageRateFlag"},
279 {187, C<&ISystemSettingsServer::GetTouchScreenMode>, "GetTouchScreenMode"}, 279 {187, C<&ISystemSettingsServer::GetTouchScreenMode>, "GetTouchScreenMode"},
@@ -306,6 +306,20 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_)
306 RegisterHandlers(functions); 306 RegisterHandlers(functions);
307 307
308 SetupSettings(); 308 SetupSettings();
309
310 m_system_settings.region_code =
311 static_cast<SystemRegionCode>(::Settings::values.region_index.GetValue());
312
313 // TODO: Remove this when starter applet is fully functional
314 EulaVersion eula_version{
315 .version = 0x10000,
316 .region_code = m_system_settings.region_code,
317 .clock_type = EulaVersionClockType::SteadyClock,
318 .system_clock_context = m_system_settings.user_system_clock_context,
319 };
320 m_system_settings.eula_versions[0] = eula_version;
321 m_system_settings.eula_version_count = 1;
322
309 m_save_thread = 323 m_save_thread =
310 std::jthread([this](std::stop_token stop_token) { StoreSettingsThreadFunc(stop_token); }); 324 std::jthread([this](std::stop_token stop_token) { StoreSettingsThreadFunc(stop_token); });
311} 325}
@@ -701,7 +715,7 @@ Result ISystemSettingsServer::GetSettingsItemValueSize(
701} 715}
702 716
703Result ISystemSettingsServer::GetSettingsItemValue( 717Result ISystemSettingsServer::GetSettingsItemValue(
704 OutBuffer<BufferAttr_HipcMapAlias> out_data, 718 Out<u64> out_size, OutBuffer<BufferAttr_HipcMapAlias> out_data,
705 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_category_buffer, 719 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_category_buffer,
706 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_name_buffer) { 720 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_name_buffer) {
707 const std::string setting_category{Common::StringFromBuffer(*setting_category_buffer)}; 721 const std::string setting_category{Common::StringFromBuffer(*setting_category_buffer)};
@@ -709,7 +723,7 @@ Result ISystemSettingsServer::GetSettingsItemValue(
709 723
710 LOG_INFO(Service_SET, "called, category={}, name={}", setting_category, setting_name); 724 LOG_INFO(Service_SET, "called, category={}, name={}", setting_category, setting_name);
711 725
712 R_RETURN(GetSettingsItemValueImpl(out_data, setting_category, setting_name)); 726 R_RETURN(GetSettingsItemValueImpl(out_data, *out_size, setting_category, setting_name));
713} 727}
714 728
715Result ISystemSettingsServer::GetTvSettings(Out<TvSettings> out_tv_settings) { 729Result ISystemSettingsServer::GetTvSettings(Out<TvSettings> out_tv_settings) {
@@ -1236,6 +1250,18 @@ Result ISystemSettingsServer::GetHomeMenuScheme(Out<HomeMenuScheme> out_home_men
1236 R_SUCCEED(); 1250 R_SUCCEED();
1237} 1251}
1238 1252
1253Result ISystemSettingsServer::GetPlatformRegion(Out<PlatformRegion> out_platform_region) {
1254 LOG_WARNING(Service_SET, "(STUBBED) called");
1255
1256 *out_platform_region = PlatformRegion::Global;
1257 R_SUCCEED();
1258}
1259
1260Result ISystemSettingsServer::SetPlatformRegion(PlatformRegion platform_region) {
1261 LOG_WARNING(Service_SET, "(STUBBED) called");
1262 R_SUCCEED();
1263}
1264
1239Result ISystemSettingsServer::GetHomeMenuSchemeModel(Out<u32> out_home_menu_scheme_model) { 1265Result ISystemSettingsServer::GetHomeMenuSchemeModel(Out<u32> out_home_menu_scheme_model) {
1240 LOG_WARNING(Service_SET, "(STUBBED) called"); 1266 LOG_WARNING(Service_SET, "(STUBBED) called");
1241 1267
@@ -1349,13 +1375,16 @@ void ISystemSettingsServer::SetSaveNeeded() {
1349 m_save_needed = true; 1375 m_save_needed = true;
1350} 1376}
1351 1377
1352Result ISystemSettingsServer::GetSettingsItemValueImpl(std::vector<u8>& out_value, 1378Result ISystemSettingsServer::GetSettingsItemValueImpl(std::span<u8> out_value, u64& out_size,
1353 const std::string& category, 1379 const std::string& category,
1354 const std::string& name) { 1380 const std::string& name) {
1355 auto settings{GetSettings()}; 1381 auto settings{GetSettings()};
1356 R_UNLESS(settings.contains(category) && settings[category].contains(name), ResultUnknown); 1382 R_UNLESS(settings.contains(category) && settings[category].contains(name), ResultUnknown);
1357 1383
1358 out_value = settings[category][name]; 1384 ASSERT_MSG(out_value.size() >= settings[category][name].size(),
1385 "Stored type is bigger than requested type");
1386 out_size = std::min<u64>(settings[category][name].size(), out_value.size());
1387 std::memcpy(out_value.data(), settings[category][name].data(), out_size);
1359 R_SUCCEED(); 1388 R_SUCCEED();
1360} 1389}
1361 1390
diff --git a/src/core/hle/service/set/system_settings_server.h b/src/core/hle/service/set/system_settings_server.h
index 46e06c8ea..993e5de7d 100644
--- a/src/core/hle/service/set/system_settings_server.h
+++ b/src/core/hle/service/set/system_settings_server.h
@@ -34,20 +34,17 @@ public:
34 explicit ISystemSettingsServer(Core::System& system_); 34 explicit ISystemSettingsServer(Core::System& system_);
35 ~ISystemSettingsServer() override; 35 ~ISystemSettingsServer() override;
36 36
37 Result GetSettingsItemValueImpl(std::vector<u8>& out_value, const std::string& category, 37 Result GetSettingsItemValueImpl(std::span<u8> out_value, u64& out_size,
38 const std::string& name); 38 const std::string& category, const std::string& name);
39 39
40 template <typename T> 40 template <typename T>
41 Result GetSettingsItemValueImpl(T& value, const std::string& category, 41 Result GetSettingsItemValueImpl(T& out_value, const std::string& category,
42 const std::string& name) { 42 const std::string& name) {
43 std::vector<u8> data; 43 u64 data_size{};
44 const auto result = GetSettingsItemValueImpl(data, category, name); 44 std::vector<u8> data(sizeof(T));
45 if (result.IsError()) { 45 R_TRY(GetSettingsItemValueImpl(data, data_size, category, name));
46 return result; 46 std::memcpy(&out_value, data.data(), data_size);
47 } 47 R_SUCCEED();
48 ASSERT(data.size() >= sizeof(T));
49 std::memcpy(&value, data.data(), sizeof(T));
50 return result;
51 } 48 }
52 49
53public: 50public:
@@ -84,7 +81,7 @@ public:
84 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_category_buffer, 81 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_category_buffer,
85 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_name_buf); 82 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_name_buf);
86 Result GetSettingsItemValue( 83 Result GetSettingsItemValue(
87 OutBuffer<BufferAttr_HipcMapAlias> out_data, 84 Out<u64> out_size, OutBuffer<BufferAttr_HipcMapAlias> out_data,
88 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_category_buffer, 85 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_category_buffer,
89 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_name_buffer); 86 InLargeData<SettingItemName, BufferAttr_HipcPointer> setting_name_buffer);
90 Result GetTvSettings(Out<TvSettings> out_tv_settings); 87 Result GetTvSettings(Out<TvSettings> out_tv_settings);
@@ -152,6 +149,8 @@ public:
152 Result GetHomeMenuScheme(Out<HomeMenuScheme> out_home_menu_scheme); 149 Result GetHomeMenuScheme(Out<HomeMenuScheme> out_home_menu_scheme);
153 Result GetHomeMenuSchemeModel(Out<u32> out_home_menu_scheme_model); 150 Result GetHomeMenuSchemeModel(Out<u32> out_home_menu_scheme_model);
154 Result GetTouchScreenMode(Out<TouchScreenMode> out_touch_screen_mode); 151 Result GetTouchScreenMode(Out<TouchScreenMode> out_touch_screen_mode);
152 Result GetPlatformRegion(Out<PlatformRegion> out_platform_region);
153 Result SetPlatformRegion(PlatformRegion platform_region);
155 Result SetTouchScreenMode(TouchScreenMode touch_screen_mode); 154 Result SetTouchScreenMode(TouchScreenMode touch_screen_mode);
156 Result GetFieldTestingFlag(Out<bool> out_field_testing_flag); 155 Result GetFieldTestingFlag(Out<bool> out_field_testing_flag);
157 Result GetPanelCrcMode(Out<s32> out_panel_crc_mode); 156 Result GetPanelCrcMode(Out<s32> out_panel_crc_mode);
diff --git a/src/core/hle/service/ssl/cert_store.cpp b/src/core/hle/service/ssl/cert_store.cpp
new file mode 100644
index 000000000..b321e5d32
--- /dev/null
+++ b/src/core/hle/service/ssl/cert_store.cpp
@@ -0,0 +1,156 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "common/alignment.h"
5#include "core/core.h"
6#include "core/file_sys/content_archive.h"
7#include "core/file_sys/nca_metadata.h"
8#include "core/file_sys/registered_cache.h"
9#include "core/file_sys/romfs.h"
10#include "core/hle/service/filesystem/filesystem.h"
11#include "core/hle/service/ssl/cert_store.h"
12
13namespace Service::SSL {
14
15// https://switchbrew.org/wiki/SSL_services#CertStore
16
17CertStore::CertStore(Core::System& system) {
18 constexpr u64 CertStoreDataId = 0x0100000000000800ULL;
19
20 auto& fsc = system.GetFileSystemController();
21
22 // Attempt to load certificate data from storage
23 const auto nca =
24 fsc.GetSystemNANDContents()->GetEntry(CertStoreDataId, FileSys::ContentRecordType::Data);
25 if (!nca) {
26 return;
27 }
28 const auto romfs = nca->GetRomFS();
29 if (!romfs) {
30 return;
31 }
32 const auto extracted = FileSys::ExtractRomFS(romfs);
33 if (!extracted) {
34 LOG_ERROR(Service_SSL, "CertStore could not be extracted, corrupt RomFS?");
35 return;
36 }
37 const auto cert_store_file = extracted->GetFile("ssl_TrustedCerts.bdf");
38 if (!cert_store_file) {
39 LOG_ERROR(Service_SSL, "Failed to find trusted certificates in CertStore");
40 return;
41 }
42
43 // Read and verify the header.
44 CertStoreHeader header;
45 cert_store_file->ReadObject(std::addressof(header));
46
47 if (header.magic != Common::MakeMagic('s', 's', 'l', 'T')) {
48 LOG_ERROR(Service_SSL, "Invalid certificate store magic");
49 return;
50 }
51
52 // Ensure the file can contains the number of entries it says it does.
53 const u64 expected_size = sizeof(header) + sizeof(CertStoreEntry) * header.num_entries;
54 const u64 actual_size = cert_store_file->GetSize();
55 if (actual_size < expected_size) {
56 LOG_ERROR(Service_SSL, "Size mismatch, expected at least {} bytes, got {}", expected_size,
57 actual_size);
58 return;
59 }
60
61 // Read entries.
62 std::vector<CertStoreEntry> entries(header.num_entries);
63 cert_store_file->ReadArray(entries.data(), header.num_entries, sizeof(header));
64
65 // Insert into memory store.
66 for (const auto& entry : entries) {
67 m_certs.emplace(entry.certificate_id,
68 Certificate{
69 .status = entry.certificate_status,
70 .der_data = cert_store_file->ReadBytes(
71 entry.der_size, entry.der_offset + sizeof(header)),
72 });
73 }
74}
75
76CertStore::~CertStore() = default;
77
78template <typename F>
79void CertStore::ForEachCertificate(std::span<const CaCertificateId> certificate_ids, F&& f) {
80 if (certificate_ids.size() == 1 && certificate_ids.front() == CaCertificateId::All) {
81 for (const auto& entry : m_certs) {
82 f(entry);
83 }
84 } else {
85 for (const auto certificate_id : certificate_ids) {
86 const auto entry = m_certs.find(certificate_id);
87 if (entry == m_certs.end()) {
88 continue;
89 }
90 f(*entry);
91 }
92 }
93}
94
95Result CertStore::GetCertificates(u32* out_num_entries, std::span<u8> out_data,
96 std::span<const CaCertificateId> certificate_ids) {
97 // Ensure the buffer is large enough to hold the output.
98 u32 required_size;
99 R_TRY(this->GetCertificateBufSize(std::addressof(required_size), out_num_entries,
100 certificate_ids));
101 R_UNLESS(out_data.size_bytes() >= required_size, ResultUnknown);
102
103 // Make parallel arrays.
104 std::vector<BuiltInCertificateInfo> cert_infos;
105 std::vector<u8> der_datas;
106
107 const u32 der_data_offset = (*out_num_entries + 1) * sizeof(BuiltInCertificateInfo);
108 u32 cur_der_offset = der_data_offset;
109
110 // Fill output.
111 this->ForEachCertificate(certificate_ids, [&](auto& entry) {
112 const auto& [status, cur_der_data] = entry.second;
113 BuiltInCertificateInfo cert_info{
114 .cert_id = entry.first,
115 .status = status,
116 .der_size = cur_der_data.size(),
117 .der_offset = cur_der_offset,
118 };
119
120 cert_infos.push_back(cert_info);
121 der_datas.insert(der_datas.end(), cur_der_data.begin(), cur_der_data.end());
122 cur_der_offset += static_cast<u32>(cur_der_data.size());
123 });
124
125 // Append terminator entry.
126 cert_infos.push_back(BuiltInCertificateInfo{
127 .cert_id = CaCertificateId::All,
128 .status = TrustedCertStatus::Invalid,
129 .der_size = 0,
130 .der_offset = 0,
131 });
132
133 // Write to output span.
134 std::memcpy(out_data.data(), cert_infos.data(),
135 cert_infos.size() * sizeof(BuiltInCertificateInfo));
136 std::memcpy(out_data.data() + der_data_offset, der_datas.data(), der_datas.size());
137
138 R_SUCCEED();
139}
140
141Result CertStore::GetCertificateBufSize(u32* out_size, u32* out_num_entries,
142 std::span<const CaCertificateId> certificate_ids) {
143 // Output size is at least the size of the terminator entry.
144 *out_size = sizeof(BuiltInCertificateInfo);
145 *out_num_entries = 0;
146
147 this->ForEachCertificate(certificate_ids, [&](auto& entry) {
148 *out_size += sizeof(BuiltInCertificateInfo);
149 *out_size += Common::AlignUp(static_cast<u32>(entry.second.der_data.size()), 4);
150 (*out_num_entries)++;
151 });
152
153 R_SUCCEED();
154}
155
156} // namespace Service::SSL
diff --git a/src/core/hle/service/ssl/cert_store.h b/src/core/hle/service/ssl/cert_store.h
new file mode 100644
index 000000000..613d7b02a
--- /dev/null
+++ b/src/core/hle/service/ssl/cert_store.h
@@ -0,0 +1,42 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include <map>
7#include <span>
8#include <vector>
9
10#include "core/hle/result.h"
11#include "core/hle/service/ssl/ssl_types.h"
12
13namespace Core {
14class System;
15}
16
17namespace Service::SSL {
18
19class CertStore {
20public:
21 explicit CertStore(Core::System& system);
22 ~CertStore();
23
24 Result GetCertificates(u32* out_num_entries, std::span<u8> out_data,
25 std::span<const CaCertificateId> certificate_ids);
26 Result GetCertificateBufSize(u32* out_size, u32* out_num_entries,
27 std::span<const CaCertificateId> certificate_ids);
28
29private:
30 template <typename F>
31 void ForEachCertificate(std::span<const CaCertificateId> certs, F&& f);
32
33private:
34 struct Certificate {
35 TrustedCertStatus status;
36 std::vector<u8> der_data;
37 };
38
39 std::map<CaCertificateId, Certificate> m_certs;
40};
41
42} // namespace Service::SSL
diff --git a/src/core/hle/service/ssl/ssl.cpp b/src/core/hle/service/ssl/ssl.cpp
index 0fbb43057..008ee4492 100644
--- a/src/core/hle/service/ssl/ssl.cpp
+++ b/src/core/hle/service/ssl/ssl.cpp
@@ -5,11 +5,13 @@
5 5
6#include "core/core.h" 6#include "core/core.h"
7#include "core/hle/result.h" 7#include "core/hle/result.h"
8#include "core/hle/service/cmif_serialization.h"
8#include "core/hle/service/ipc_helpers.h" 9#include "core/hle/service/ipc_helpers.h"
9#include "core/hle/service/server_manager.h" 10#include "core/hle/service/server_manager.h"
10#include "core/hle/service/service.h" 11#include "core/hle/service/service.h"
11#include "core/hle/service/sm/sm.h" 12#include "core/hle/service/sm/sm.h"
12#include "core/hle/service/sockets/bsd.h" 13#include "core/hle/service/sockets/bsd.h"
14#include "core/hle/service/ssl/cert_store.h"
13#include "core/hle/service/ssl/ssl.h" 15#include "core/hle/service/ssl/ssl.h"
14#include "core/hle/service/ssl/ssl_backend.h" 16#include "core/hle/service/ssl/ssl_backend.h"
15#include "core/internal_network/network.h" 17#include "core/internal_network/network.h"
@@ -492,13 +494,14 @@ private:
492 494
493class ISslService final : public ServiceFramework<ISslService> { 495class ISslService final : public ServiceFramework<ISslService> {
494public: 496public:
495 explicit ISslService(Core::System& system_) : ServiceFramework{system_, "ssl"} { 497 explicit ISslService(Core::System& system_)
498 : ServiceFramework{system_, "ssl"}, cert_store{system} {
496 // clang-format off 499 // clang-format off
497 static const FunctionInfo functions[] = { 500 static const FunctionInfo functions[] = {
498 {0, &ISslService::CreateContext, "CreateContext"}, 501 {0, &ISslService::CreateContext, "CreateContext"},
499 {1, nullptr, "GetContextCount"}, 502 {1, nullptr, "GetContextCount"},
500 {2, nullptr, "GetCertificates"}, 503 {2, D<&ISslService::GetCertificates>, "GetCertificates"},
501 {3, nullptr, "GetCertificateBufSize"}, 504 {3, D<&ISslService::GetCertificateBufSize>, "GetCertificateBufSize"},
502 {4, nullptr, "DebugIoctl"}, 505 {4, nullptr, "DebugIoctl"},
503 {5, &ISslService::SetInterfaceVersion, "SetInterfaceVersion"}, 506 {5, &ISslService::SetInterfaceVersion, "SetInterfaceVersion"},
504 {6, nullptr, "FlushSessionCache"}, 507 {6, nullptr, "FlushSessionCache"},
@@ -540,6 +543,22 @@ private:
540 IPC::ResponseBuilder rb{ctx, 2}; 543 IPC::ResponseBuilder rb{ctx, 2};
541 rb.Push(ResultSuccess); 544 rb.Push(ResultSuccess);
542 } 545 }
546
547 Result GetCertificateBufSize(
548 Out<u32> out_size, InArray<CaCertificateId, BufferAttr_HipcMapAlias> certificate_ids) {
549 LOG_INFO(Service_SSL, "called");
550 u32 num_entries;
551 R_RETURN(cert_store.GetCertificateBufSize(out_size, &num_entries, certificate_ids));
552 }
553
554 Result GetCertificates(Out<u32> out_num_entries, OutBuffer<BufferAttr_HipcMapAlias> out_buffer,
555 InArray<CaCertificateId, BufferAttr_HipcMapAlias> certificate_ids) {
556 LOG_INFO(Service_SSL, "called");
557 R_RETURN(cert_store.GetCertificates(out_num_entries, out_buffer, certificate_ids));
558 }
559
560private:
561 CertStore cert_store;
543}; 562};
544 563
545void LoopProcess(Core::System& system) { 564void LoopProcess(Core::System& system) {
diff --git a/src/core/hle/service/ssl/ssl_types.h b/src/core/hle/service/ssl/ssl_types.h
new file mode 100644
index 000000000..dbc3dbf64
--- /dev/null
+++ b/src/core/hle/service/ssl/ssl_types.h
@@ -0,0 +1,107 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include "common/common_types.h"
7
8namespace Service::SSL {
9
10enum class CaCertificateId : s32 {
11 All = -1,
12 NintendoCAG3 = 1,
13 NintendoClass2CAG3 = 2,
14 NintendoRootCAG4 = 3,
15 AmazonRootCA1 = 1000,
16 StarfieldServicesRootCertificateAuthorityG2 = 1001,
17 AddTrustExternalCARoot = 1002,
18 COMODOCertificationAuthority = 1003,
19 UTNDATACorpSGC = 1004,
20 UTNUSERFirstHardware = 1005,
21 BaltimoreCyberTrustRoot = 1006,
22 CybertrustGlobalRoot = 1007,
23 VerizonGlobalRootCA = 1008,
24 DigiCertAssuredIDRootCA = 1009,
25 DigiCertAssuredIDRootG2 = 1010,
26 DigiCertGlobalRootCA = 1011,
27 DigiCertGlobalRootG2 = 1012,
28 DigiCertHighAssuranceEVRootCA = 1013,
29 EntrustnetCertificationAuthority2048 = 1014,
30 EntrustRootCertificationAuthority = 1015,
31 EntrustRootCertificationAuthorityG2 = 1016,
32 GeoTrustGlobalCA2 = 1017,
33 GeoTrustGlobalCA = 1018,
34 GeoTrustPrimaryCertificationAuthorityG3 = 1019,
35 GeoTrustPrimaryCertificationAuthority = 1020,
36 GlobalSignRootCA = 1021,
37 GlobalSignRootCAR2 = 1022,
38 GlobalSignRootCAR3 = 1023,
39 GoDaddyClass2CertificationAuthority = 1024,
40 GoDaddyRootCertificateAuthorityG2 = 1025,
41 StarfieldClass2CertificationAuthority = 1026,
42 StarfieldRootCertificateAuthorityG2 = 1027,
43 thawtePrimaryRootCAG3 = 1028,
44 thawtePrimaryRootCA = 1029,
45 VeriSignClass3PublicPrimaryCertificationAuthorityG3 = 1030,
46 VeriSignClass3PublicPrimaryCertificationAuthorityG5 = 1031,
47 VeriSignUniversalRootCertificationAuthority = 1032,
48 DSTRootCAX3 = 1033,
49 USERTrustRsaCertificationAuthority = 1034,
50 ISRGRootX10 = 1035,
51 USERTrustEccCertificationAuthority = 1036,
52 COMODORsaCertificationAuthority = 1037,
53 COMODOEccCertificationAuthority = 1038,
54 AmazonRootCA2 = 1039,
55 AmazonRootCA3 = 1040,
56 AmazonRootCA4 = 1041,
57 DigiCertAssuredIDRootG3 = 1042,
58 DigiCertGlobalRootG3 = 1043,
59 DigiCertTrustedRootG4 = 1044,
60 EntrustRootCertificationAuthorityEC1 = 1045,
61 EntrustRootCertificationAuthorityG4 = 1046,
62 GlobalSignECCRootCAR4 = 1047,
63 GlobalSignECCRootCAR5 = 1048,
64 GlobalSignECCRootCAR6 = 1049,
65 GTSRootR1 = 1050,
66 GTSRootR2 = 1051,
67 GTSRootR3 = 1052,
68 GTSRootR4 = 1053,
69 SecurityCommunicationRootCA = 1054,
70 GlobalSignRootE4 = 1055,
71 GlobalSignRootR4 = 1056,
72 TTeleSecGlobalRootClass2 = 1057,
73 DigiCertTLSECCP384RootG5 = 1058,
74 DigiCertTLSRSA4096RootG5 = 1059,
75};
76
77enum class TrustedCertStatus : s32 {
78 Invalid = -1,
79 Removed = 0,
80 EnabledTrusted = 1,
81 EnabledNotTrusted = 2,
82 Revoked = 3,
83};
84
85struct BuiltInCertificateInfo {
86 CaCertificateId cert_id;
87 TrustedCertStatus status;
88 u64 der_size;
89 u64 der_offset;
90};
91static_assert(sizeof(BuiltInCertificateInfo) == 0x18, "BuiltInCertificateInfo has incorrect size.");
92
93struct CertStoreHeader {
94 u32 magic;
95 u32 num_entries;
96};
97static_assert(sizeof(CertStoreHeader) == 0x8, "CertStoreHeader has incorrect size.");
98
99struct CertStoreEntry {
100 CaCertificateId certificate_id;
101 TrustedCertStatus certificate_status;
102 u32 der_size;
103 u32 der_offset;
104};
105static_assert(sizeof(CertStoreEntry) == 0x10, "CertStoreEntry has incorrect size.");
106
107} // namespace Service::SSL
diff --git a/src/hid_core/frontend/emulated_controller.cpp b/src/hid_core/frontend/emulated_controller.cpp
index 5cd26819c..9aa08d5cc 100644
--- a/src/hid_core/frontend/emulated_controller.cpp
+++ b/src/hid_core/frontend/emulated_controller.cpp
@@ -2,6 +2,7 @@
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 <chrono>
5#include <common/scope_exit.h> 6#include <common/scope_exit.h>
6 7
7#include "common/polyfill_ranges.h" 8#include "common/polyfill_ranges.h"
@@ -175,10 +176,9 @@ void EmulatedController::LoadDevices() {
175 if (npad_id_type == NpadIdType::Player1 || npad_id_type == NpadIdType::Handheld) { 176 if (npad_id_type == NpadIdType::Player1 || npad_id_type == NpadIdType::Handheld) {
176 camera_params[1] = Common::ParamPackage{"engine:camera,camera:1"}; 177 camera_params[1] = Common::ParamPackage{"engine:camera,camera:1"};
177 nfc_params[0] = Common::ParamPackage{"engine:virtual_amiibo,nfc:1"}; 178 nfc_params[0] = Common::ParamPackage{"engine:virtual_amiibo,nfc:1"};
178#ifdef HAVE_LIBUSB 179#ifndef ANDROID
179 ring_params[1] = Common::ParamPackage{"engine:joycon,axis_x:100,axis_y:101"}; 180 ring_params[1] = Common::ParamPackage{"engine:joycon,axis_x:100,axis_y:101"};
180#endif 181#else
181#ifdef ANDROID
182 android_params = Common::ParamPackage{"engine:android,port:100"}; 182 android_params = Common::ParamPackage{"engine:android,port:100"};
183#endif 183#endif
184 } 184 }
@@ -1287,6 +1287,22 @@ bool EmulatedController::SetVibration(DeviceIndex device_index, const VibrationV
1287 return false; 1287 return false;
1288 } 1288 }
1289 1289
1290 if (!Settings::values.enable_accurate_vibrations.GetValue()) {
1291 using std::chrono::duration_cast;
1292 using std::chrono::milliseconds;
1293 using std::chrono::steady_clock;
1294
1295 const auto now = steady_clock::now();
1296
1297 // Filter out non-zero vibrations that are within 15ms of each other.
1298 if ((vibration.low_amplitude != 0.0f || vibration.high_amplitude != 0.0f) &&
1299 duration_cast<milliseconds>(now - last_vibration_timepoint[index]) < milliseconds(15)) {
1300 return false;
1301 }
1302
1303 last_vibration_timepoint[index] = now;
1304 }
1305
1290 // Exponential amplification is too strong at low amplitudes. Switch to a linear 1306 // Exponential amplification is too strong at low amplitudes. Switch to a linear
1291 // amplification if strength is set below 0.7f 1307 // amplification if strength is set below 0.7f
1292 const Common::Input::VibrationAmplificationType type = 1308 const Common::Input::VibrationAmplificationType type =
diff --git a/src/hid_core/frontend/emulated_controller.h b/src/hid_core/frontend/emulated_controller.h
index ab3c6fcd3..17ad6069e 100644
--- a/src/hid_core/frontend/emulated_controller.h
+++ b/src/hid_core/frontend/emulated_controller.h
@@ -583,6 +583,7 @@ private:
583 std::size_t nfc_handles{0}; 583 std::size_t nfc_handles{0};
584 std::array<VibrationValue, 2> last_vibration_value{DEFAULT_VIBRATION_VALUE, 584 std::array<VibrationValue, 2> last_vibration_value{DEFAULT_VIBRATION_VALUE,
585 DEFAULT_VIBRATION_VALUE}; 585 DEFAULT_VIBRATION_VALUE};
586 std::array<std::chrono::steady_clock::time_point, 2> last_vibration_timepoint{};
586 587
587 // Temporary values to avoid doing changes while the controller is in configuring mode 588 // Temporary values to avoid doing changes while the controller is in configuring mode
588 NpadStyleIndex tmp_npad_type{NpadStyleIndex::None}; 589 NpadStyleIndex tmp_npad_type{NpadStyleIndex::None};
diff --git a/src/hid_core/hid_types.h b/src/hid_core/hid_types.h
index 165ecf9de..40a90c2bc 100644
--- a/src/hid_core/hid_types.h
+++ b/src/hid_core/hid_types.h
@@ -630,7 +630,11 @@ struct VibrationValue {
630 if (low_amplitude != b.low_amplitude || high_amplitude != b.high_amplitude) { 630 if (low_amplitude != b.low_amplitude || high_amplitude != b.high_amplitude) {
631 return false; 631 return false;
632 } 632 }
633 if (low_frequency != b.low_amplitude || high_frequency != b.high_frequency) { 633 // Changes in frequency without amplitude don't have any effect
634 if (low_amplitude == 0 && high_amplitude == 0) {
635 return true;
636 }
637 if (low_frequency != b.low_frequency || high_frequency != b.high_frequency) {
634 return false; 638 return false;
635 } 639 }
636 return true; 640 return true;
diff --git a/src/hid_core/resources/npad/npad.cpp b/src/hid_core/resources/npad/npad.cpp
index e10e97e1c..ca1ccd659 100644
--- a/src/hid_core/resources/npad/npad.cpp
+++ b/src/hid_core/resources/npad/npad.cpp
@@ -3,7 +3,6 @@
3 3
4#include <algorithm> 4#include <algorithm>
5#include <array> 5#include <array>
6#include <chrono>
7#include <cstring> 6#include <cstring>
8 7
9#include "common/assert.h" 8#include "common/assert.h"
diff --git a/src/input_common/drivers/android.cpp b/src/input_common/drivers/android.cpp
index e859cc538..d40fa66ae 100644
--- a/src/input_common/drivers/android.cpp
+++ b/src/input_common/drivers/android.cpp
@@ -3,6 +3,7 @@
3 3
4#include <set> 4#include <set>
5#include <common/settings_input.h> 5#include <common/settings_input.h>
6#include <common/thread.h>
6#include <jni.h> 7#include <jni.h>
7#include "common/android/android_common.h" 8#include "common/android/android_common.h"
8#include "common/android/id_cache.h" 9#include "common/android/id_cache.h"
@@ -10,7 +11,18 @@
10 11
11namespace InputCommon { 12namespace InputCommon {
12 13
13Android::Android(std::string input_engine_) : InputEngine(std::move(input_engine_)) {} 14Android::Android(std::string input_engine_) : InputEngine(std::move(input_engine_)) {
15 vibration_thread = std::jthread([this](std::stop_token token) {
16 Common::SetCurrentThreadName("Android_Vibration");
17 auto env = Common::Android::GetEnvForThread();
18 using namespace std::chrono_literals;
19 while (!token.stop_requested()) {
20 SendVibrations(env, token);
21 }
22 });
23}
24
25Android::~Android() = default;
14 26
15void Android::RegisterController(jobject j_input_device) { 27void Android::RegisterController(jobject j_input_device) {
16 auto env = Common::Android::GetEnvForThread(); 28 auto env = Common::Android::GetEnvForThread();
@@ -57,17 +69,11 @@ void Android::SetMotionState(std::string guid, size_t port, u64 delta_timestamp,
57Common::Input::DriverResult Android::SetVibration( 69Common::Input::DriverResult Android::SetVibration(
58 [[maybe_unused]] const PadIdentifier& identifier, 70 [[maybe_unused]] const PadIdentifier& identifier,
59 [[maybe_unused]] const Common::Input::VibrationStatus& vibration) { 71 [[maybe_unused]] const Common::Input::VibrationStatus& vibration) {
60 auto device = input_devices.find(identifier); 72 vibration_queue.Push(VibrationRequest{
61 if (device != input_devices.end()) { 73 .identifier = identifier,
62 Common::Android::RunJNIOnFiber<void>([&](JNIEnv* env) { 74 .vibration = vibration,
63 float average_intensity = 75 });
64 static_cast<float>((vibration.high_amplitude + vibration.low_amplitude) / 2.0); 76 return Common::Input::DriverResult::Success;
65 env->CallVoidMethod(device->second, Common::Android::GetYuzuDeviceVibrate(),
66 average_intensity);
67 });
68 return Common::Input::DriverResult::Success;
69 }
70 return Common::Input::DriverResult::NotSupported;
71} 77}
72 78
73bool Android::IsVibrationEnabled([[maybe_unused]] const PadIdentifier& identifier) { 79bool Android::IsVibrationEnabled([[maybe_unused]] const PadIdentifier& identifier) {
@@ -347,4 +353,15 @@ PadIdentifier Android::GetIdentifier(const std::string& guid, size_t port) const
347 }; 353 };
348} 354}
349 355
356void Android::SendVibrations(JNIEnv* env, std::stop_token token) {
357 VibrationRequest request = vibration_queue.PopWait(token);
358 auto device = input_devices.find(request.identifier);
359 if (device != input_devices.end()) {
360 float average_intensity = static_cast<float>(
361 (request.vibration.high_amplitude + request.vibration.low_amplitude) / 2.0);
362 env->CallVoidMethod(device->second, Common::Android::GetYuzuDeviceVibrate(),
363 average_intensity);
364 }
365}
366
350} // namespace InputCommon 367} // namespace InputCommon
diff --git a/src/input_common/drivers/android.h b/src/input_common/drivers/android.h
index 8a386c1b1..03e2b2c98 100644
--- a/src/input_common/drivers/android.h
+++ b/src/input_common/drivers/android.h
@@ -4,6 +4,7 @@
4#pragma once 4#pragma once
5 5
6#include <set> 6#include <set>
7#include <common/threadsafe_queue.h>
7#include <jni.h> 8#include <jni.h>
8#include "input_common/input_engine.h" 9#include "input_common/input_engine.h"
9 10
@@ -16,6 +17,8 @@ class Android final : public InputEngine {
16public: 17public:
17 explicit Android(std::string input_engine_); 18 explicit Android(std::string input_engine_);
18 19
20 ~Android() override;
21
19 /** 22 /**
20 * Registers controller number to accept new inputs. 23 * Registers controller number to accept new inputs.
21 * @param j_input_device YuzuInputDevice object from the Android frontend to register. 24 * @param j_input_device YuzuInputDevice object from the Android frontend to register.
@@ -89,6 +92,9 @@ private:
89 /// Returns the correct identifier corresponding to the player index 92 /// Returns the correct identifier corresponding to the player index
90 PadIdentifier GetIdentifier(const std::string& guid, size_t port) const; 93 PadIdentifier GetIdentifier(const std::string& guid, size_t port) const;
91 94
95 /// Takes all vibrations from the queue and sends the command to the controller
96 void SendVibrations(JNIEnv* env, std::stop_token token);
97
92 static constexpr s32 AXIS_X = 0; 98 static constexpr s32 AXIS_X = 0;
93 static constexpr s32 AXIS_Y = 1; 99 static constexpr s32 AXIS_Y = 1;
94 static constexpr s32 AXIS_Z = 11; 100 static constexpr s32 AXIS_Z = 11;
@@ -133,6 +139,10 @@ private:
133 redmagic_vid, backbone_labs_vid, xbox_vid}; 139 redmagic_vid, backbone_labs_vid, xbox_vid};
134 const std::vector<std::string> flipped_xy_vids{sony_vid, razer_vid, redmagic_vid, 140 const std::vector<std::string> flipped_xy_vids{sony_vid, razer_vid, redmagic_vid,
135 backbone_labs_vid, xbox_vid}; 141 backbone_labs_vid, xbox_vid};
142
143 /// Queue of vibration request to controllers
144 Common::SPSCQueue<VibrationRequest> vibration_queue;
145 std::jthread vibration_thread;
136}; 146};
137 147
138} // namespace InputCommon 148} // namespace InputCommon
diff --git a/src/input_common/drivers/sdl_driver.h b/src/input_common/drivers/sdl_driver.h
index 08e49a0da..a140ad072 100644
--- a/src/input_common/drivers/sdl_driver.h
+++ b/src/input_common/drivers/sdl_driver.h
@@ -69,11 +69,6 @@ public:
69 bool IsVibrationEnabled(const PadIdentifier& identifier) override; 69 bool IsVibrationEnabled(const PadIdentifier& identifier) override;
70 70
71private: 71private:
72 struct VibrationRequest {
73 PadIdentifier identifier;
74 Common::Input::VibrationStatus vibration;
75 };
76
77 void InitJoystick(int joystick_index); 72 void InitJoystick(int joystick_index);
78 void CloseJoystick(SDL_Joystick* sdl_joystick); 73 void CloseJoystick(SDL_Joystick* sdl_joystick);
79 74
diff --git a/src/input_common/input_engine.h b/src/input_common/input_engine.h
index c2d0cbb34..3e328509b 100644
--- a/src/input_common/input_engine.h
+++ b/src/input_common/input_engine.h
@@ -46,6 +46,11 @@ enum class EngineInputType {
46 Nfc, 46 Nfc,
47}; 47};
48 48
49struct VibrationRequest {
50 PadIdentifier identifier;
51 Common::Input::VibrationStatus vibration;
52};
53
49namespace std { 54namespace std {
50// Hash used to create lists from PadIdentifier data 55// Hash used to create lists from PadIdentifier data
51template <> 56template <>
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h
index ed7a5b27e..af237703d 100644
--- a/src/video_core/buffer_cache/buffer_cache.h
+++ b/src/video_core/buffer_cache/buffer_cache.h
@@ -1488,7 +1488,10 @@ void BufferCache<P>::ImmediateUploadMemory([[maybe_unused]] Buffer& buffer,
1488 std::span<const u8> upload_span; 1488 std::span<const u8> upload_span;
1489 const DAddr device_addr = buffer.CpuAddr() + copy.dst_offset; 1489 const DAddr device_addr = buffer.CpuAddr() + copy.dst_offset;
1490 if (IsRangeGranular(device_addr, copy.size)) { 1490 if (IsRangeGranular(device_addr, copy.size)) {
1491 upload_span = std::span(device_memory.GetPointer<u8>(device_addr), copy.size); 1491 auto* const ptr = device_memory.GetPointer<u8>(device_addr);
1492 if (ptr != nullptr) {
1493 upload_span = std::span(ptr, copy.size);
1494 }
1492 } else { 1495 } else {
1493 if (immediate_buffer.empty()) { 1496 if (immediate_buffer.empty()) {
1494 immediate_buffer = ImmediateBuffer(largest_copy); 1497 immediate_buffer = ImmediateBuffer(largest_copy);
diff --git a/src/video_core/buffer_cache/usage_tracker.h b/src/video_core/buffer_cache/usage_tracker.h
index 5f8688d31..ae511ccb6 100644
--- a/src/video_core/buffer_cache/usage_tracker.h
+++ b/src/video_core/buffer_cache/usage_tracker.h
@@ -26,6 +26,9 @@ public:
26 void Track(u64 offset, u64 size) noexcept { 26 void Track(u64 offset, u64 size) noexcept {
27 const size_t page = offset >> PAGE_SHIFT; 27 const size_t page = offset >> PAGE_SHIFT;
28 const size_t page_end = (offset + size) >> PAGE_SHIFT; 28 const size_t page_end = (offset + size) >> PAGE_SHIFT;
29 if (page_end < page || page_end >= pages.size()) {
30 return;
31 }
29 TrackPage(page, offset, size); 32 TrackPage(page, offset, size);
30 if (page == page_end) { 33 if (page == page_end) {
31 return; 34 return;
@@ -41,6 +44,9 @@ public:
41 [[nodiscard]] bool IsUsed(u64 offset, u64 size) const noexcept { 44 [[nodiscard]] bool IsUsed(u64 offset, u64 size) const noexcept {
42 const size_t page = offset >> PAGE_SHIFT; 45 const size_t page = offset >> PAGE_SHIFT;
43 const size_t page_end = (offset + size) >> PAGE_SHIFT; 46 const size_t page_end = (offset + size) >> PAGE_SHIFT;
47 if (page_end < page || page_end >= pages.size()) {
48 return false;
49 }
44 if (IsPageUsed(page, offset, size)) { 50 if (IsPageUsed(page, offset, size)) {
45 return true; 51 return true;
46 } 52 }
diff --git a/src/video_core/control/channel_state.cpp b/src/video_core/control/channel_state.cpp
index 832025d75..2539997d5 100644
--- a/src/video_core/control/channel_state.cpp
+++ b/src/video_core/control/channel_state.cpp
@@ -16,8 +16,9 @@ namespace Tegra::Control {
16 16
17ChannelState::ChannelState(s32 bind_id_) : bind_id{bind_id_}, initialized{} {} 17ChannelState::ChannelState(s32 bind_id_) : bind_id{bind_id_}, initialized{} {}
18 18
19void ChannelState::Init(Core::System& system, GPU& gpu) { 19void ChannelState::Init(Core::System& system, GPU& gpu, u64 program_id_) {
20 ASSERT(memory_manager); 20 ASSERT(memory_manager);
21 program_id = program_id_;
21 dma_pusher = std::make_unique<Tegra::DmaPusher>(system, gpu, *memory_manager, *this); 22 dma_pusher = std::make_unique<Tegra::DmaPusher>(system, gpu, *memory_manager, *this);
22 maxwell_3d = std::make_unique<Engines::Maxwell3D>(system, *memory_manager); 23 maxwell_3d = std::make_unique<Engines::Maxwell3D>(system, *memory_manager);
23 fermi_2d = std::make_unique<Engines::Fermi2D>(*memory_manager); 24 fermi_2d = std::make_unique<Engines::Fermi2D>(*memory_manager);
diff --git a/src/video_core/control/channel_state.h b/src/video_core/control/channel_state.h
index 3a7b9872c..b385f4939 100644
--- a/src/video_core/control/channel_state.h
+++ b/src/video_core/control/channel_state.h
@@ -40,11 +40,12 @@ struct ChannelState {
40 ChannelState(ChannelState&& other) noexcept = default; 40 ChannelState(ChannelState&& other) noexcept = default;
41 ChannelState& operator=(ChannelState&& other) noexcept = default; 41 ChannelState& operator=(ChannelState&& other) noexcept = default;
42 42
43 void Init(Core::System& system, GPU& gpu); 43 void Init(Core::System& system, GPU& gpu, u64 program_id);
44 44
45 void BindRasterizer(VideoCore::RasterizerInterface* rasterizer); 45 void BindRasterizer(VideoCore::RasterizerInterface* rasterizer);
46 46
47 s32 bind_id = -1; 47 s32 bind_id = -1;
48 u64 program_id = 0;
48 /// 3D engine 49 /// 3D engine
49 std::unique_ptr<Engines::Maxwell3D> maxwell_3d; 50 std::unique_ptr<Engines::Maxwell3D> maxwell_3d;
50 /// 2D engine 51 /// 2D engine
diff --git a/src/video_core/control/channel_state_cache.cpp b/src/video_core/control/channel_state_cache.cpp
index 4ebeb6356..f8c6a762d 100644
--- a/src/video_core/control/channel_state_cache.cpp
+++ b/src/video_core/control/channel_state_cache.cpp
@@ -7,7 +7,7 @@ namespace VideoCommon {
7 7
8ChannelInfo::ChannelInfo(Tegra::Control::ChannelState& channel_state) 8ChannelInfo::ChannelInfo(Tegra::Control::ChannelState& channel_state)
9 : maxwell3d{*channel_state.maxwell_3d}, kepler_compute{*channel_state.kepler_compute}, 9 : maxwell3d{*channel_state.maxwell_3d}, kepler_compute{*channel_state.kepler_compute},
10 gpu_memory{*channel_state.memory_manager} {} 10 gpu_memory{*channel_state.memory_manager}, program_id{channel_state.program_id} {}
11 11
12template class VideoCommon::ChannelSetupCaches<VideoCommon::ChannelInfo>; 12template class VideoCommon::ChannelSetupCaches<VideoCommon::ChannelInfo>;
13 13
diff --git a/src/video_core/control/channel_state_cache.h b/src/video_core/control/channel_state_cache.h
index 1dbfda299..7480d60d1 100644
--- a/src/video_core/control/channel_state_cache.h
+++ b/src/video_core/control/channel_state_cache.h
@@ -39,6 +39,7 @@ public:
39 Tegra::Engines::Maxwell3D& maxwell3d; 39 Tegra::Engines::Maxwell3D& maxwell3d;
40 Tegra::Engines::KeplerCompute& kepler_compute; 40 Tegra::Engines::KeplerCompute& kepler_compute;
41 Tegra::MemoryManager& gpu_memory; 41 Tegra::MemoryManager& gpu_memory;
42 u64 program_id;
42}; 43};
43 44
44template <class P> 45template <class P>
@@ -77,9 +78,10 @@ protected:
77 P* channel_state; 78 P* channel_state;
78 size_t current_channel_id{UNSET_CHANNEL}; 79 size_t current_channel_id{UNSET_CHANNEL};
79 size_t current_address_space{}; 80 size_t current_address_space{};
80 Tegra::Engines::Maxwell3D* maxwell3d; 81 Tegra::Engines::Maxwell3D* maxwell3d{};
81 Tegra::Engines::KeplerCompute* kepler_compute; 82 Tegra::Engines::KeplerCompute* kepler_compute{};
82 Tegra::MemoryManager* gpu_memory; 83 Tegra::MemoryManager* gpu_memory{};
84 u64 program_id{};
83 85
84 std::deque<P> channel_storage; 86 std::deque<P> channel_storage;
85 std::deque<size_t> free_channel_ids; 87 std::deque<size_t> free_channel_ids;
diff --git a/src/video_core/control/channel_state_cache.inc b/src/video_core/control/channel_state_cache.inc
index 31f792ddd..d882d8222 100644
--- a/src/video_core/control/channel_state_cache.inc
+++ b/src/video_core/control/channel_state_cache.inc
@@ -58,6 +58,7 @@ void ChannelSetupCaches<P>::BindToChannel(s32 id) {
58 maxwell3d = &channel_state->maxwell3d; 58 maxwell3d = &channel_state->maxwell3d;
59 kepler_compute = &channel_state->kepler_compute; 59 kepler_compute = &channel_state->kepler_compute;
60 gpu_memory = &channel_state->gpu_memory; 60 gpu_memory = &channel_state->gpu_memory;
61 program_id = channel_state->program_id;
61 current_address_space = gpu_memory->GetID(); 62 current_address_space = gpu_memory->GetID();
62} 63}
63 64
@@ -76,6 +77,7 @@ void ChannelSetupCaches<P>::EraseChannel(s32 id) {
76 maxwell3d = nullptr; 77 maxwell3d = nullptr;
77 kepler_compute = nullptr; 78 kepler_compute = nullptr;
78 gpu_memory = nullptr; 79 gpu_memory = nullptr;
80 program_id = 0;
79 } else if (current_channel_id != UNSET_CHANNEL) { 81 } else if (current_channel_id != UNSET_CHANNEL) {
80 channel_state = &channel_storage[current_channel_id]; 82 channel_state = &channel_storage[current_channel_id];
81 } 83 }
diff --git a/src/video_core/engines/draw_manager.cpp b/src/video_core/engines/draw_manager.cpp
index d77ff455b..971025cb5 100644
--- a/src/video_core/engines/draw_manager.cpp
+++ b/src/video_core/engines/draw_manager.cpp
@@ -216,14 +216,11 @@ void DrawManager::DrawTexture() {
216 const bool lower_left{regs.window_origin.mode != 216 const bool lower_left{regs.window_origin.mode !=
217 Maxwell3D::Regs::WindowOrigin::Mode::UpperLeft}; 217 Maxwell3D::Regs::WindowOrigin::Mode::UpperLeft};
218 if (lower_left) { 218 if (lower_left) {
219 draw_texture_state.dst_y0 -= dst_height; 219 draw_texture_state.dst_y0 =
220 static_cast<f32>(regs.surface_clip.height) - draw_texture_state.dst_y0;
220 } 221 }
221 draw_texture_state.dst_x1 = 222 draw_texture_state.dst_x1 = draw_texture_state.dst_x0 + dst_width;
222 draw_texture_state.dst_x0 + 223 draw_texture_state.dst_y1 = draw_texture_state.dst_y0 + dst_height;
223 static_cast<f32>(Settings::values.resolution_info.ScaleUp(static_cast<u32>(dst_width)));
224 draw_texture_state.dst_y1 =
225 draw_texture_state.dst_y0 +
226 static_cast<f32>(Settings::values.resolution_info.ScaleUp(static_cast<u32>(dst_height)));
227 draw_texture_state.src_x0 = static_cast<float>(regs.draw_texture.src_x0) / 4096.f; 224 draw_texture_state.src_x0 = static_cast<float>(regs.draw_texture.src_x0) / 4096.f;
228 draw_texture_state.src_y0 = static_cast<float>(regs.draw_texture.src_y0) / 4096.f; 225 draw_texture_state.src_y0 = static_cast<float>(regs.draw_texture.src_y0) / 4096.f;
229 draw_texture_state.src_x1 = 226 draw_texture_state.src_x1 =
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp
index 8e663f2a8..6d0b32339 100644
--- a/src/video_core/gpu.cpp
+++ b/src/video_core/gpu.cpp
@@ -67,8 +67,8 @@ struct GPU::Impl {
67 return CreateChannel(new_channel_id++); 67 return CreateChannel(new_channel_id++);
68 } 68 }
69 69
70 void InitChannel(Control::ChannelState& to_init) { 70 void InitChannel(Control::ChannelState& to_init, u64 program_id) {
71 to_init.Init(system, gpu); 71 to_init.Init(system, gpu, program_id);
72 to_init.BindRasterizer(rasterizer); 72 to_init.BindRasterizer(rasterizer);
73 rasterizer->InitializeChannel(to_init); 73 rasterizer->InitializeChannel(to_init);
74 } 74 }
@@ -412,8 +412,8 @@ std::shared_ptr<Control::ChannelState> GPU::AllocateChannel() {
412 return impl->AllocateChannel(); 412 return impl->AllocateChannel();
413} 413}
414 414
415void GPU::InitChannel(Control::ChannelState& to_init) { 415void GPU::InitChannel(Control::ChannelState& to_init, u64 program_id) {
416 impl->InitChannel(to_init); 416 impl->InitChannel(to_init, program_id);
417} 417}
418 418
419void GPU::BindChannel(s32 channel_id) { 419void GPU::BindChannel(s32 channel_id) {
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h
index ad535512c..50014e51f 100644
--- a/src/video_core/gpu.h
+++ b/src/video_core/gpu.h
@@ -149,7 +149,7 @@ public:
149 149
150 std::shared_ptr<Control::ChannelState> AllocateChannel(); 150 std::shared_ptr<Control::ChannelState> AllocateChannel();
151 151
152 void InitChannel(Control::ChannelState& to_init); 152 void InitChannel(Control::ChannelState& to_init, u64 program_id);
153 153
154 void BindChannel(s32 channel_id); 154 void BindChannel(s32 channel_id);
155 155
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 16af8e6bd..d376d86d8 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -370,27 +370,32 @@ void RasterizerOpenGL::DrawTexture() {
370 const auto& sampler = texture_cache.GetGraphicsSampler(draw_texture_state.src_sampler); 370 const auto& sampler = texture_cache.GetGraphicsSampler(draw_texture_state.src_sampler);
371 const auto& texture = texture_cache.GetImageView(draw_texture_state.src_texture); 371 const auto& texture = texture_cache.GetImageView(draw_texture_state.src_texture);
372 372
373 const auto Scale = [&](auto dim) -> s32 {
374 return Settings::values.resolution_info.ScaleUp(static_cast<s32>(dim));
375 };
376
377 Region2D dst_region = {
378 Offset2D{.x = Scale(draw_texture_state.dst_x0), .y = Scale(draw_texture_state.dst_y0)},
379 Offset2D{.x = Scale(draw_texture_state.dst_x1), .y = Scale(draw_texture_state.dst_y1)}};
380 Region2D src_region = {
381 Offset2D{.x = Scale(draw_texture_state.src_x0), .y = Scale(draw_texture_state.src_y0)},
382 Offset2D{.x = Scale(draw_texture_state.src_x1), .y = Scale(draw_texture_state.src_y1)}};
383 Extent3D src_size = {static_cast<u32>(Scale(texture.size.width)),
384 static_cast<u32>(Scale(texture.size.height)), texture.size.depth};
385
373 if (device.HasDrawTexture()) { 386 if (device.HasDrawTexture()) {
374 state_tracker.BindFramebuffer(texture_cache.GetFramebuffer()->Handle()); 387 state_tracker.BindFramebuffer(texture_cache.GetFramebuffer()->Handle());
375 388
376 glDrawTextureNV(texture.DefaultHandle(), sampler->Handle(), draw_texture_state.dst_x0, 389 glDrawTextureNV(texture.DefaultHandle(), sampler->Handle(),
377 draw_texture_state.dst_y0, draw_texture_state.dst_x1, 390 static_cast<f32>(dst_region.start.x), static_cast<f32>(dst_region.start.y),
378 draw_texture_state.dst_y1, 0, 391 static_cast<f32>(dst_region.end.x), static_cast<f32>(dst_region.end.y), 0,
379 draw_texture_state.src_x0 / static_cast<float>(texture.size.width), 392 draw_texture_state.src_x0 / static_cast<float>(texture.size.width),
380 draw_texture_state.src_y0 / static_cast<float>(texture.size.height), 393 draw_texture_state.src_y0 / static_cast<float>(texture.size.height),
381 draw_texture_state.src_x1 / static_cast<float>(texture.size.width), 394 draw_texture_state.src_x1 / static_cast<float>(texture.size.width),
382 draw_texture_state.src_y1 / static_cast<float>(texture.size.height)); 395 draw_texture_state.src_y1 / static_cast<float>(texture.size.height));
383 } else { 396 } else {
384 Region2D dst_region = {Offset2D{.x = static_cast<s32>(draw_texture_state.dst_x0),
385 .y = static_cast<s32>(draw_texture_state.dst_y0)},
386 Offset2D{.x = static_cast<s32>(draw_texture_state.dst_x1),
387 .y = static_cast<s32>(draw_texture_state.dst_y1)}};
388 Region2D src_region = {Offset2D{.x = static_cast<s32>(draw_texture_state.src_x0),
389 .y = static_cast<s32>(draw_texture_state.src_y0)},
390 Offset2D{.x = static_cast<s32>(draw_texture_state.src_x1),
391 .y = static_cast<s32>(draw_texture_state.src_y1)}};
392 blit_image.BlitColor(texture_cache.GetFramebuffer()->Handle(), texture.DefaultHandle(), 397 blit_image.BlitColor(texture_cache.GetFramebuffer()->Handle(), texture.DefaultHandle(),
393 sampler->Handle(), dst_region, src_region, texture.size); 398 sampler->Handle(), dst_region, src_region, src_size);
394 state_tracker.InvalidateState(); 399 state_tracker.InvalidateState();
395 } 400 }
396 401
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp
index 50462cdde..c4bad6fca 100644
--- a/src/video_core/renderer_opengl/gl_shader_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp
@@ -215,6 +215,7 @@ ShaderCache::ShaderCache(Tegra::MaxwellDeviceMemoryManager& device_memory_,
215 .support_gl_variable_aoffi = device.HasVariableAoffi(), 215 .support_gl_variable_aoffi = device.HasVariableAoffi(),
216 .support_gl_sparse_textures = device.HasSparseTexture2(), 216 .support_gl_sparse_textures = device.HasSparseTexture2(),
217 .support_gl_derivative_control = device.HasDerivativeControl(), 217 .support_gl_derivative_control = device.HasDerivativeControl(),
218 .support_geometry_streams = true,
218 219
219 .warp_size_potentially_larger_than_guest = device.IsWarpSizePotentiallyLargerThanGuest(), 220 .warp_size_potentially_larger_than_guest = device.IsWarpSizePotentiallyLargerThanGuest(),
220 221
diff --git a/src/video_core/renderer_vulkan/vk_query_cache.cpp b/src/video_core/renderer_vulkan/vk_query_cache.cpp
index 7cbc9c73c..a28296bda 100644
--- a/src/video_core/renderer_vulkan/vk_query_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_query_cache.cpp
@@ -1064,8 +1064,6 @@ public:
1064 } 1064 }
1065 }); 1065 });
1066 } 1066 }
1067 auto* ptr = device_memory.GetPointer<u8>(new_query->dependant_address);
1068 ASSERT(ptr != nullptr);
1069 1067
1070 new_query->dependant_manage = must_manage_dependance; 1068 new_query->dependant_manage = must_manage_dependance;
1071 pending_flush_queries.push_back(index); 1069 pending_flush_queries.push_back(index);
@@ -1104,9 +1102,11 @@ public:
1104 tfb_streamer.Free(query->dependant_index); 1102 tfb_streamer.Free(query->dependant_index);
1105 } else { 1103 } else {
1106 u8* pointer = device_memory.GetPointer<u8>(query->dependant_address); 1104 u8* pointer = device_memory.GetPointer<u8>(query->dependant_address);
1107 u32 result; 1105 if (pointer != nullptr) {
1108 std::memcpy(&result, pointer, sizeof(u32)); 1106 u32 result;
1109 num_vertices = static_cast<u64>(result) / query->stride; 1107 std::memcpy(&result, pointer, sizeof(u32));
1108 num_vertices = static_cast<u64>(result) / query->stride;
1109 }
1110 } 1110 }
1111 query->value = [&]() -> u64 { 1111 query->value = [&]() -> u64 {
1112 switch (query->topology) { 1112 switch (query->topology) {
@@ -1360,7 +1360,9 @@ bool QueryCacheRuntime::HostConditionalRenderingCompareValues(VideoCommon::Looku
1360 const auto check_value = [&](DAddr address) { 1360 const auto check_value = [&](DAddr address) {
1361 u8* ptr = impl->device_memory.GetPointer<u8>(address); 1361 u8* ptr = impl->device_memory.GetPointer<u8>(address);
1362 u64 value{}; 1362 u64 value{};
1363 std::memcpy(&value, ptr, sizeof(value)); 1363 if (ptr != nullptr) {
1364 std::memcpy(&value, ptr, sizeof(value));
1365 }
1364 return value == 0; 1366 return value == 0;
1365 }; 1367 };
1366 std::array<VideoCommon::LookupData*, 2> objects{&object_1, &object_2}; 1368 std::array<VideoCommon::LookupData*, 2> objects{&object_1, &object_2};
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
index 74f9f099e..8ba50a834 100644
--- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp
+++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
@@ -125,11 +125,23 @@ VkRect2D GetScissorState(const Maxwell& regs, size_t index, u32 up_scale = 1, u3
125 return value < 0 ? std::min<s32>(converted_value - acumm, -1) 125 return value < 0 ? std::min<s32>(converted_value - acumm, -1)
126 : std::max<s32>(converted_value + acumm, 1); 126 : std::max<s32>(converted_value + acumm, 1);
127 }; 127 };
128
129 const bool lower_left = regs.window_origin.mode != Maxwell::WindowOrigin::Mode::UpperLeft;
130 const s32 clip_height = regs.surface_clip.height;
131
132 // Flip coordinates if lower left
133 s32 min_y = lower_left ? (clip_height - src.max_y) : src.min_y.Value();
134 s32 max_y = lower_left ? (clip_height - src.min_y) : src.max_y.Value();
135
136 // Bound to render area
137 min_y = std::max(min_y, 0);
138 max_y = std::max(max_y, 0);
139
128 if (src.enable) { 140 if (src.enable) {
129 scissor.offset.x = scale_up(static_cast<s32>(src.min_x)); 141 scissor.offset.x = scale_up(src.min_x);
130 scissor.offset.y = scale_up(static_cast<s32>(src.min_y)); 142 scissor.offset.y = scale_up(min_y);
131 scissor.extent.width = scale_up(src.max_x - src.min_x); 143 scissor.extent.width = scale_up(src.max_x - src.min_x);
132 scissor.extent.height = scale_up(src.max_y - src.min_y); 144 scissor.extent.height = scale_up(max_y - min_y);
133 } else { 145 } else {
134 scissor.offset.x = 0; 146 scissor.offset.x = 0;
135 scissor.offset.y = 0; 147 scissor.offset.y = 0;
@@ -308,17 +320,33 @@ void RasterizerVulkan::DrawTexture() {
308 const auto& draw_texture_state = maxwell3d->draw_manager->GetDrawTextureState(); 320 const auto& draw_texture_state = maxwell3d->draw_manager->GetDrawTextureState();
309 const auto& sampler = texture_cache.GetGraphicsSampler(draw_texture_state.src_sampler); 321 const auto& sampler = texture_cache.GetGraphicsSampler(draw_texture_state.src_sampler);
310 const auto& texture = texture_cache.GetImageView(draw_texture_state.src_texture); 322 const auto& texture = texture_cache.GetImageView(draw_texture_state.src_texture);
311 Region2D dst_region = {Offset2D{.x = static_cast<s32>(draw_texture_state.dst_x0), 323 const auto* framebuffer = texture_cache.GetFramebuffer();
312 .y = static_cast<s32>(draw_texture_state.dst_y0)}, 324
313 Offset2D{.x = static_cast<s32>(draw_texture_state.dst_x1), 325 const bool src_rescaling = texture_cache.IsRescaling() && texture.IsRescaled();
314 .y = static_cast<s32>(draw_texture_state.dst_y1)}}; 326 const bool dst_rescaling = texture_cache.IsRescaling() && framebuffer->IsRescaled();
315 Region2D src_region = {Offset2D{.x = static_cast<s32>(draw_texture_state.src_x0), 327
316 .y = static_cast<s32>(draw_texture_state.src_y0)}, 328 const auto ScaleSrc = [&](auto dim_f) -> s32 {
317 Offset2D{.x = static_cast<s32>(draw_texture_state.src_x1), 329 auto dim = static_cast<s32>(dim_f);
318 .y = static_cast<s32>(draw_texture_state.src_y1)}}; 330 return src_rescaling ? Settings::values.resolution_info.ScaleUp(dim) : dim;
319 blit_image.BlitColor(texture_cache.GetFramebuffer(), texture.RenderTarget(), 331 };
320 texture.ImageHandle(), sampler->Handle(), dst_region, src_region, 332
321 texture.size); 333 const auto ScaleDst = [&](auto dim_f) -> s32 {
334 auto dim = static_cast<s32>(dim_f);
335 return dst_rescaling ? Settings::values.resolution_info.ScaleUp(dim) : dim;
336 };
337
338 Region2D dst_region = {Offset2D{.x = ScaleDst(draw_texture_state.dst_x0),
339 .y = ScaleDst(draw_texture_state.dst_y0)},
340 Offset2D{.x = ScaleDst(draw_texture_state.dst_x1),
341 .y = ScaleDst(draw_texture_state.dst_y1)}};
342 Region2D src_region = {Offset2D{.x = ScaleSrc(draw_texture_state.src_x0),
343 .y = ScaleSrc(draw_texture_state.src_y0)},
344 Offset2D{.x = ScaleSrc(draw_texture_state.src_x1),
345 .y = ScaleSrc(draw_texture_state.src_y1)}};
346 Extent3D src_size = {static_cast<u32>(ScaleSrc(texture.size.width)),
347 static_cast<u32>(ScaleSrc(texture.size.height)), texture.size.depth};
348 blit_image.BlitColor(framebuffer, texture.RenderTarget(), texture.ImageHandle(),
349 sampler->Handle(), dst_region, src_region, src_size);
322} 350}
323 351
324void RasterizerVulkan::Clear(u32 layer_count) { 352void RasterizerVulkan::Clear(u32 layer_count) {
@@ -1054,37 +1082,16 @@ void RasterizerVulkan::UpdateDepthBias(Tegra::Engines::Maxwell3D::Regs& regs) {
1054 regs.zeta.format == Tegra::DepthFormat::X8Z24_UNORM || 1082 regs.zeta.format == Tegra::DepthFormat::X8Z24_UNORM ||
1055 regs.zeta.format == Tegra::DepthFormat::S8Z24_UNORM || 1083 regs.zeta.format == Tegra::DepthFormat::S8Z24_UNORM ||
1056 regs.zeta.format == Tegra::DepthFormat::V8Z24_UNORM; 1084 regs.zeta.format == Tegra::DepthFormat::V8Z24_UNORM;
1057 bool force_unorm = ([&] { 1085 if (is_d24 && !device.SupportsD24DepthBuffer() && program_id == 0x1006A800016E000ULL) {
1058 if (!is_d24 || device.SupportsD24DepthBuffer()) { 1086 // Only activate this in Super Smash Brothers Ultimate
1059 return false;
1060 }
1061 if (device.IsExtDepthBiasControlSupported()) {
1062 return true;
1063 }
1064 if (!Settings::values.renderer_amdvlk_depth_bias_workaround) {
1065 return false;
1066 }
1067 // the base formulas can be obtained from here: 1087 // the base formulas can be obtained from here:
1068 // https://docs.microsoft.com/en-us/windows/win32/direct3d11/d3d10-graphics-programming-guide-output-merger-stage-depth-bias 1088 // https://docs.microsoft.com/en-us/windows/win32/direct3d11/d3d10-graphics-programming-guide-output-merger-stage-depth-bias
1069 const double rescale_factor = 1089 const double rescale_factor =
1070 static_cast<double>(1ULL << (32 - 24)) / (static_cast<double>(0x1.ep+127)); 1090 static_cast<double>(1ULL << (32 - 24)) / (static_cast<double>(0x1.ep+127));
1071 units = static_cast<float>(static_cast<double>(units) * rescale_factor); 1091 units = static_cast<float>(static_cast<double>(units) * rescale_factor);
1072 return false; 1092 }
1073 })();
1074 scheduler.Record([constant = units, clamp = regs.depth_bias_clamp, 1093 scheduler.Record([constant = units, clamp = regs.depth_bias_clamp,
1075 factor = regs.slope_scale_depth_bias, force_unorm, 1094 factor = regs.slope_scale_depth_bias](vk::CommandBuffer cmdbuf) {
1076 precise = device.HasExactDepthBiasControl()](vk::CommandBuffer cmdbuf) {
1077 if (force_unorm) {
1078 VkDepthBiasRepresentationInfoEXT info{
1079 .sType = VK_STRUCTURE_TYPE_DEPTH_BIAS_REPRESENTATION_INFO_EXT,
1080 .pNext = nullptr,
1081 .depthBiasRepresentation =
1082 VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORCE_UNORM_EXT,
1083 .depthBiasExact = precise ? VK_TRUE : VK_FALSE,
1084 };
1085 cmdbuf.SetDepthBias(constant, clamp, factor, &info);
1086 return;
1087 }
1088 cmdbuf.SetDepthBias(constant, clamp, factor); 1095 cmdbuf.SetDepthBias(constant, clamp, factor);
1089 }); 1096 });
1090} 1097}
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp
index 832b5e2b1..6d4deb0eb 100644
--- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp
@@ -1962,21 +1962,22 @@ Framebuffer::Framebuffer(TextureCacheRuntime& runtime, std::span<ImageView*, NUM
1962} 1962}
1963 1963
1964Framebuffer::Framebuffer(TextureCacheRuntime& runtime, ImageView* color_buffer, 1964Framebuffer::Framebuffer(TextureCacheRuntime& runtime, ImageView* color_buffer,
1965 ImageView* depth_buffer, VkExtent2D extent, bool is_rescaled) 1965 ImageView* depth_buffer, VkExtent2D extent, bool is_rescaled_)
1966 : render_area{extent} { 1966 : render_area{extent} {
1967 std::array<ImageView*, NUM_RT> color_buffers{color_buffer}; 1967 std::array<ImageView*, NUM_RT> color_buffers{color_buffer};
1968 CreateFramebuffer(runtime, color_buffers, depth_buffer, is_rescaled); 1968 CreateFramebuffer(runtime, color_buffers, depth_buffer, is_rescaled_);
1969} 1969}
1970 1970
1971Framebuffer::~Framebuffer() = default; 1971Framebuffer::~Framebuffer() = default;
1972 1972
1973void Framebuffer::CreateFramebuffer(TextureCacheRuntime& runtime, 1973void Framebuffer::CreateFramebuffer(TextureCacheRuntime& runtime,
1974 std::span<ImageView*, NUM_RT> color_buffers, 1974 std::span<ImageView*, NUM_RT> color_buffers,
1975 ImageView* depth_buffer, bool is_rescaled) { 1975 ImageView* depth_buffer, bool is_rescaled_) {
1976 boost::container::small_vector<VkImageView, NUM_RT + 1> attachments; 1976 boost::container::small_vector<VkImageView, NUM_RT + 1> attachments;
1977 RenderPassKey renderpass_key{}; 1977 RenderPassKey renderpass_key{};
1978 s32 num_layers = 1; 1978 s32 num_layers = 1;
1979 1979
1980 is_rescaled = is_rescaled_;
1980 const auto& resolution = runtime.resolution; 1981 const auto& resolution = runtime.resolution;
1981 1982
1982 u32 width = std::numeric_limits<u32>::max(); 1983 u32 width = std::numeric_limits<u32>::max();
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.h b/src/video_core/renderer_vulkan/vk_texture_cache.h
index aaeb5ef93..8501ec384 100644
--- a/src/video_core/renderer_vulkan/vk_texture_cache.h
+++ b/src/video_core/renderer_vulkan/vk_texture_cache.h
@@ -361,6 +361,10 @@ public:
361 return has_stencil; 361 return has_stencil;
362 } 362 }
363 363
364 [[nodiscard]] bool IsRescaled() const noexcept {
365 return is_rescaled;
366 }
367
364private: 368private:
365 vk::Framebuffer framebuffer; 369 vk::Framebuffer framebuffer;
366 VkRenderPass renderpass{}; 370 VkRenderPass renderpass{};
@@ -373,6 +377,7 @@ private:
373 std::array<size_t, NUM_RT> rt_map{}; 377 std::array<size_t, NUM_RT> rt_map{};
374 bool has_depth{}; 378 bool has_depth{};
375 bool has_stencil{}; 379 bool has_stencil{};
380 bool is_rescaled{};
376}; 381};
377 382
378struct TextureCacheParams { 383struct TextureCacheParams {
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index 53b4876f2..feb1c575e 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -72,12 +72,19 @@ TextureCache<P>::TextureCache(Runtime& runtime_, Tegra::MaxwellDeviceMemoryManag
72 72
73template <class P> 73template <class P>
74void TextureCache<P>::RunGarbageCollector() { 74void TextureCache<P>::RunGarbageCollector() {
75 bool high_priority_mode = total_used_memory >= expected_memory; 75 bool high_priority_mode = false;
76 bool aggressive_mode = total_used_memory >= critical_memory; 76 bool aggressive_mode = false;
77 const u64 ticks_to_destroy = aggressive_mode ? 10ULL : high_priority_mode ? 25ULL : 50ULL; 77 u64 ticks_to_destroy = 0;
78 size_t num_iterations = aggressive_mode ? 40 : (high_priority_mode ? 20 : 10); 78 size_t num_iterations = 0;
79 const auto clean_up = [this, &num_iterations, &high_priority_mode, 79
80 &aggressive_mode](ImageId image_id) { 80 const auto Configure = [&](bool allow_aggressive) {
81 high_priority_mode = total_used_memory >= expected_memory;
82 aggressive_mode = allow_aggressive && total_used_memory >= critical_memory;
83 ticks_to_destroy = aggressive_mode ? 10ULL : high_priority_mode ? 25ULL : 50ULL;
84 num_iterations = aggressive_mode ? 40 : (high_priority_mode ? 20 : 10);
85 };
86 const auto Cleanup = [this, &num_iterations, &high_priority_mode,
87 &aggressive_mode](ImageId image_id) {
81 if (num_iterations == 0) { 88 if (num_iterations == 0) {
82 return true; 89 return true;
83 } 90 }
@@ -123,7 +130,16 @@ void TextureCache<P>::RunGarbageCollector() {
123 } 130 }
124 return false; 131 return false;
125 }; 132 };
126 lru_cache.ForEachItemBelow(frame_tick - ticks_to_destroy, clean_up); 133
134 // Try to remove anything old enough and not high priority.
135 Configure(false);
136 lru_cache.ForEachItemBelow(frame_tick - ticks_to_destroy, Cleanup);
137
138 // If pressure is still too high, prune aggressively.
139 if (total_used_memory >= critical_memory) {
140 Configure(true);
141 lru_cache.ForEachItemBelow(frame_tick - ticks_to_destroy, Cleanup);
142 }
127} 143}
128 144
129template <class P> 145template <class P>
@@ -2098,7 +2114,9 @@ void TextureCache<P>::TrackImage(ImageBase& image, ImageId image_id) {
2098 ASSERT(False(image.flags & ImageFlagBits::Tracked)); 2114 ASSERT(False(image.flags & ImageFlagBits::Tracked));
2099 image.flags |= ImageFlagBits::Tracked; 2115 image.flags |= ImageFlagBits::Tracked;
2100 if (False(image.flags & ImageFlagBits::Sparse)) { 2116 if (False(image.flags & ImageFlagBits::Sparse)) {
2101 device_memory.UpdatePagesCachedCount(image.cpu_addr, image.guest_size_bytes, 1); 2117 if (image.cpu_addr < ~(1ULL << 40)) {
2118 device_memory.UpdatePagesCachedCount(image.cpu_addr, image.guest_size_bytes, 1);
2119 }
2102 return; 2120 return;
2103 } 2121 }
2104 if (True(image.flags & ImageFlagBits::Registered)) { 2122 if (True(image.flags & ImageFlagBits::Registered)) {
@@ -2124,7 +2142,9 @@ void TextureCache<P>::UntrackImage(ImageBase& image, ImageId image_id) {
2124 ASSERT(True(image.flags & ImageFlagBits::Tracked)); 2142 ASSERT(True(image.flags & ImageFlagBits::Tracked));
2125 image.flags &= ~ImageFlagBits::Tracked; 2143 image.flags &= ~ImageFlagBits::Tracked;
2126 if (False(image.flags & ImageFlagBits::Sparse)) { 2144 if (False(image.flags & ImageFlagBits::Sparse)) {
2127 device_memory.UpdatePagesCachedCount(image.cpu_addr, image.guest_size_bytes, -1); 2145 if (image.cpu_addr < ~(1ULL << 40)) {
2146 device_memory.UpdatePagesCachedCount(image.cpu_addr, image.guest_size_bytes, -1);
2147 }
2128 return; 2148 return;
2129 } 2149 }
2130 ASSERT(True(image.flags & ImageFlagBits::Registered)); 2150 ASSERT(True(image.flags & ImageFlagBits::Registered));
diff --git a/src/yuzu/configuration/configure_applets.cpp b/src/yuzu/configuration/configure_applets.cpp
index 513ecb548..139bfa9da 100644
--- a/src/yuzu/configuration/configure_applets.cpp
+++ b/src/yuzu/configuration/configure_applets.cpp
@@ -59,9 +59,7 @@ void ConfigureApplets::Setup(const ConfigurationShared::Builder& builder) {
59 59
60 // Untested applets 60 // Untested applets
61 if (setting->Id() == Settings::values.data_erase_applet_mode.Id() || 61 if (setting->Id() == Settings::values.data_erase_applet_mode.Id() ||
62 setting->Id() == Settings::values.error_applet_mode.Id() ||
63 setting->Id() == Settings::values.net_connect_applet_mode.Id() || 62 setting->Id() == Settings::values.net_connect_applet_mode.Id() ||
64 setting->Id() == Settings::values.web_applet_mode.Id() ||
65 setting->Id() == Settings::values.shop_applet_mode.Id() || 63 setting->Id() == Settings::values.shop_applet_mode.Id() ||
66 setting->Id() == Settings::values.login_share_applet_mode.Id() || 64 setting->Id() == Settings::values.login_share_applet_mode.Id() ||
67 setting->Id() == Settings::values.wifi_web_auth_applet_mode.Id() || 65 setting->Id() == Settings::values.wifi_web_auth_applet_mode.Id() ||
diff --git a/tools/reset-submodules.sh b/tools/reset-submodules.sh
new file mode 100755
index 000000000..6fdfe0bcd
--- /dev/null
+++ b/tools/reset-submodules.sh
@@ -0,0 +1,8 @@
1#!/bin/bash -ex
2
3# SPDX-FileCopyrightText: 2024 yuzu Emulator Project
4# SPDX-License-Identifier: MIT
5
6git submodule sync
7git submodule foreach --recursive git reset --hard
8git submodule update --init --recursive