aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xREADME.md2
-rwxr-xr-xsrc/core/hle/kernel/hle_ipc.cpp11
-rwxr-xr-xsrc/core/hle/kernel/hle_ipc.h3
-rwxr-xr-xsrc/core/hle/kernel/kernel.cpp14
-rwxr-xr-xsrc/core/hle/kernel/kernel.h16
-rwxr-xr-xsrc/core/hle/service/audio/audout_u.cpp7
-rwxr-xr-xsrc/core/hle/service/audio/audren_u.cpp3
-rwxr-xr-xsrc/core/hle/service/filesystem/fsp_srv.cpp13
-rwxr-xr-xsrc/core/hle/service/hid/hid.cpp4
-rwxr-xr-xsrc/core/hle/service/service.cpp8
-rwxr-xr-xsrc/core/hle/service/service.h15
-rwxr-xr-xsrc/core/hle/service/sm/sm.cpp2
-rwxr-xr-xsrc/core/hle/service/sockets/bsd.cpp3
-rwxr-xr-xsrc/core/hle/service/vi/vi.cpp3
14 files changed, 76 insertions, 28 deletions
diff --git a/README.md b/README.md
index 01c2da965..b47ac65bb 100755
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
1yuzu emulator early access 1yuzu emulator early access
2============= 2=============
3 3
4This is the source code for early-access 2623. 4This is the source code for early-access 2624.
5 5
6## Legal Notice 6## Legal Notice
7 7
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp
index 42d1b0e31..90e0662cf 100755
--- a/src/core/hle/kernel/hle_ipc.cpp
+++ b/src/core/hle/kernel/hle_ipc.cpp
@@ -24,8 +24,15 @@
24 24
25namespace Kernel { 25namespace Kernel {
26 26
27SessionRequestHandler::SessionRequestHandler(KernelCore& kernel_, const char* service_name_) 27SessionRequestHandler::SessionRequestHandler(KernelCore& kernel_, const char* service_name_,
28 : kernel{kernel_}, service_thread{kernel.CreateServiceThread(service_name_)} {} 28 bool create_service_thread_)
29 : kernel{kernel_} {
30 if (create_service_thread_) {
31 service_thread = kernel.CreateServiceThread(service_name_);
32 } else {
33 service_thread = kernel.GetDefaultServiceThread();
34 }
35}
29 36
30SessionRequestHandler::~SessionRequestHandler() { 37SessionRequestHandler::~SessionRequestHandler() {
31 kernel.ReleaseServiceThread(service_thread); 38 kernel.ReleaseServiceThread(service_thread);
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h
index 670cc741c..07ce83ab4 100755
--- a/src/core/hle/kernel/hle_ipc.h
+++ b/src/core/hle/kernel/hle_ipc.h
@@ -57,7 +57,8 @@ enum class ThreadWakeupReason;
57 */ 57 */
58class SessionRequestHandler : public std::enable_shared_from_this<SessionRequestHandler> { 58class SessionRequestHandler : public std::enable_shared_from_this<SessionRequestHandler> {
59public: 59public:
60 SessionRequestHandler(KernelCore& kernel, const char* service_name_); 60 SessionRequestHandler(KernelCore& kernel_, const char* service_name_,
61 bool create_service_thread_);
61 virtual ~SessionRequestHandler(); 62 virtual ~SessionRequestHandler();
62 63
63 /** 64 /**
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index df05f5ddb..763e83187 100755
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -61,6 +61,7 @@ struct KernelCore::Impl {
61 global_scheduler_context = std::make_unique<Kernel::GlobalSchedulerContext>(kernel); 61 global_scheduler_context = std::make_unique<Kernel::GlobalSchedulerContext>(kernel);
62 global_handle_table = std::make_unique<Kernel::KHandleTable>(kernel); 62 global_handle_table = std::make_unique<Kernel::KHandleTable>(kernel);
63 global_handle_table->Initialize(KHandleTable::MaxTableSize); 63 global_handle_table->Initialize(KHandleTable::MaxTableSize);
64 default_service_thread = CreateServiceThread(kernel, "DefaultServiceThread");
64 65
65 is_phantom_mode_for_singlecore = false; 66 is_phantom_mode_for_singlecore = false;
66 67
@@ -686,6 +687,12 @@ struct KernelCore::Impl {
686 687
687 void ReleaseServiceThread(std::weak_ptr<Kernel::ServiceThread> service_thread) { 688 void ReleaseServiceThread(std::weak_ptr<Kernel::ServiceThread> service_thread) {
688 if (auto strong_ptr = service_thread.lock()) { 689 if (auto strong_ptr = service_thread.lock()) {
690 if (strong_ptr == default_service_thread.lock()) {
691 // Nothing to do here, the service is using default_service_thread, which will be
692 // released on shutdown.
693 return;
694 }
695
689 service_threads_manager.QueueWork( 696 service_threads_manager.QueueWork(
690 [this, strong_ptr{std::move(strong_ptr)}]() { service_threads.erase(strong_ptr); }); 697 [this, strong_ptr{std::move(strong_ptr)}]() { service_threads.erase(strong_ptr); });
691 } 698 }
@@ -749,7 +756,8 @@ struct KernelCore::Impl {
749 std::unique_ptr<KMemoryLayout> memory_layout; 756 std::unique_ptr<KMemoryLayout> memory_layout;
750 757
751 // Threads used for services 758 // Threads used for services
752 std::unordered_set<std::shared_ptr<Kernel::ServiceThread>> service_threads; 759 std::unordered_set<std::shared_ptr<ServiceThread>> service_threads;
760 std::weak_ptr<ServiceThread> default_service_thread;
753 Common::ThreadWorker service_threads_manager; 761 Common::ThreadWorker service_threads_manager;
754 762
755 std::array<KThread*, Core::Hardware::NUM_CPU_CORES> suspend_threads; 763 std::array<KThread*, Core::Hardware::NUM_CPU_CORES> suspend_threads;
@@ -1083,6 +1091,10 @@ std::weak_ptr<Kernel::ServiceThread> KernelCore::CreateServiceThread(const std::
1083 return impl->CreateServiceThread(*this, name); 1091 return impl->CreateServiceThread(*this, name);
1084} 1092}
1085 1093
1094std::weak_ptr<Kernel::ServiceThread> KernelCore::GetDefaultServiceThread() {
1095 return impl->default_service_thread;
1096}
1097
1086void KernelCore::ReleaseServiceThread(std::weak_ptr<Kernel::ServiceThread> service_thread) { 1098void KernelCore::ReleaseServiceThread(std::weak_ptr<Kernel::ServiceThread> service_thread) {
1087 impl->ReleaseServiceThread(service_thread); 1099 impl->ReleaseServiceThread(service_thread);
1088} 1100}
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index 0757d74a7..77901e5a9 100755
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -277,9 +277,11 @@ public:
277 void ExitSVCProfile(); 277 void ExitSVCProfile();
278 278
279 /** 279 /**
280 * Creates an HLE service thread, which are used to execute service routines asynchronously. 280 * Creates a host thread to execute HLE service requests, which are used to execute service
281 * While these are allocated per ServerSession, these need to be owned and managed outside 281 * routines asynchronously. While these are allocated per ServerSession, these need to be owned
282 * of ServerSession to avoid a circular dependency. 282 * and managed outside of ServerSession to avoid a circular dependency. In general, most
283 * services can just use the default service thread, and not need their own host service thread.
284 * See GetDefaultServiceThread.
283 * @param name String name for the ServerSession creating this thread, used for debug 285 * @param name String name for the ServerSession creating this thread, used for debug
284 * purposes. 286 * purposes.
285 * @returns The a weak pointer newly created service thread. 287 * @returns The a weak pointer newly created service thread.
@@ -287,6 +289,14 @@ public:
287 std::weak_ptr<Kernel::ServiceThread> CreateServiceThread(const std::string& name); 289 std::weak_ptr<Kernel::ServiceThread> CreateServiceThread(const std::string& name);
288 290
289 /** 291 /**
292 * Gets the default host service thread, which executes HLE service requests. Unless service
293 * requests need to block on the host, the default service thread should be used in favor of
294 * creating a new service thread.
295 * @returns The a weak pointer for the default service thread.
296 */
297 std::weak_ptr<Kernel::ServiceThread> GetDefaultServiceThread();
298
299 /**
290 * Releases a HLE service thread, instructing KernelCore to free it. This should be called when 300 * Releases a HLE service thread, instructing KernelCore to free it. This should be called when
291 * the ServerSession associated with the thread is destroyed. 301 * the ServerSession associated with the thread is destroyed.
292 * @param service_thread Service thread to release. 302 * @param service_thread Service thread to release.
diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp
index affa7971c..834ac14ca 100755
--- a/src/core/hle/service/audio/audout_u.cpp
+++ b/src/core/hle/service/audio/audout_u.cpp
@@ -41,9 +41,10 @@ public:
41 explicit IAudioOut(Core::System& system_, AudoutParams audio_params_, 41 explicit IAudioOut(Core::System& system_, AudoutParams audio_params_,
42 AudioCore::AudioOut& audio_core_, std::string&& device_name_, 42 AudioCore::AudioOut& audio_core_, std::string&& device_name_,
43 std::string&& unique_name) 43 std::string&& unique_name)
44 : ServiceFramework{system_, "IAudioOut"}, audio_core{audio_core_}, 44 : ServiceFramework{system_, "IAudioOut", true /*create_service_thread*/},
45 device_name{std::move(device_name_)}, audio_params{audio_params_}, 45 audio_core{audio_core_}, device_name{std::move(device_name_)},
46 main_memory{system.Memory()}, service_context{system_, "IAudioOut"} { 46 audio_params{audio_params_}, main_memory{system.Memory()}, service_context{system_,
47 "IAudioOut"} {
47 // clang-format off 48 // clang-format off
48 static const FunctionInfo functions[] = { 49 static const FunctionInfo functions[] = {
49 {0, &IAudioOut::GetAudioOutState, "GetAudioOutState"}, 50 {0, &IAudioOut::GetAudioOutState, "GetAudioOutState"},
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp
index f45e5cecc..8df874fcf 100755
--- a/src/core/hle/service/audio/audren_u.cpp
+++ b/src/core/hle/service/audio/audren_u.cpp
@@ -24,7 +24,8 @@ public:
24 explicit IAudioRenderer(Core::System& system_, 24 explicit IAudioRenderer(Core::System& system_,
25 const AudioCommon::AudioRendererParameter& audren_params, 25 const AudioCommon::AudioRendererParameter& audren_params,
26 const std::size_t instance_number) 26 const std::size_t instance_number)
27 : ServiceFramework{system_, "IAudioRenderer"}, service_context{system_, "IAudioRenderer"} { 27 : ServiceFramework{system_, "IAudioRenderer", true /*create_service_thread*/},
28 service_context{system_, "IAudioRenderer"} {
28 // clang-format off 29 // clang-format off
29 static const FunctionInfo functions[] = { 30 static const FunctionInfo functions[] = {
30 {0, &IAudioRenderer::GetSampleRate, "GetSampleRate"}, 31 {0, &IAudioRenderer::GetSampleRate, "GetSampleRate"},
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp
index b087e7bba..9feccfbb8 100755
--- a/src/core/hle/service/filesystem/fsp_srv.cpp
+++ b/src/core/hle/service/filesystem/fsp_srv.cpp
@@ -58,7 +58,8 @@ enum class FileSystemType : u8 {
58class IStorage final : public ServiceFramework<IStorage> { 58class IStorage final : public ServiceFramework<IStorage> {
59public: 59public:
60 explicit IStorage(Core::System& system_, FileSys::VirtualFile backend_) 60 explicit IStorage(Core::System& system_, FileSys::VirtualFile backend_)
61 : ServiceFramework{system_, "IStorage"}, backend(std::move(backend_)) { 61 : ServiceFramework{system_, "IStorage", true /*create_service_thread*/},
62 backend(std::move(backend_)) {
62 static const FunctionInfo functions[] = { 63 static const FunctionInfo functions[] = {
63 {0, &IStorage::Read, "Read"}, 64 {0, &IStorage::Read, "Read"},
64 {1, nullptr, "Write"}, 65 {1, nullptr, "Write"},
@@ -116,7 +117,8 @@ private:
116class IFile final : public ServiceFramework<IFile> { 117class IFile final : public ServiceFramework<IFile> {
117public: 118public:
118 explicit IFile(Core::System& system_, FileSys::VirtualFile backend_) 119 explicit IFile(Core::System& system_, FileSys::VirtualFile backend_)
119 : ServiceFramework{system_, "IFile"}, backend(std::move(backend_)) { 120 : ServiceFramework{system_, "IFile", true /*create_service_thread*/},
121 backend(std::move(backend_)) {
120 static const FunctionInfo functions[] = { 122 static const FunctionInfo functions[] = {
121 {0, &IFile::Read, "Read"}, 123 {0, &IFile::Read, "Read"},
122 {1, &IFile::Write, "Write"}, 124 {1, &IFile::Write, "Write"},
@@ -252,7 +254,8 @@ static void BuildEntryIndex(std::vector<FileSys::Entry>& entries, const std::vec
252class IDirectory final : public ServiceFramework<IDirectory> { 254class IDirectory final : public ServiceFramework<IDirectory> {
253public: 255public:
254 explicit IDirectory(Core::System& system_, FileSys::VirtualDir backend_) 256 explicit IDirectory(Core::System& system_, FileSys::VirtualDir backend_)
255 : ServiceFramework{system_, "IDirectory"}, backend(std::move(backend_)) { 257 : ServiceFramework{system_, "IDirectory", true /*create_service_thread*/},
258 backend(std::move(backend_)) {
256 static const FunctionInfo functions[] = { 259 static const FunctionInfo functions[] = {
257 {0, &IDirectory::Read, "Read"}, 260 {0, &IDirectory::Read, "Read"},
258 {1, &IDirectory::GetEntryCount, "GetEntryCount"}, 261 {1, &IDirectory::GetEntryCount, "GetEntryCount"},
@@ -308,8 +311,8 @@ private:
308class IFileSystem final : public ServiceFramework<IFileSystem> { 311class IFileSystem final : public ServiceFramework<IFileSystem> {
309public: 312public:
310 explicit IFileSystem(Core::System& system_, FileSys::VirtualDir backend_, SizeGetter size_) 313 explicit IFileSystem(Core::System& system_, FileSys::VirtualDir backend_, SizeGetter size_)
311 : ServiceFramework{system_, "IFileSystem"}, backend{std::move(backend_)}, size{std::move( 314 : ServiceFramework{system_, "IFileSystem", true /*create_service_thread*/},
312 size_)} { 315 backend{std::move(backend_)}, size{std::move(size_)} {
313 static const FunctionInfo functions[] = { 316 static const FunctionInfo functions[] = {
314 {0, &IFileSystem::CreateFile, "CreateFile"}, 317 {0, &IFileSystem::CreateFile, "CreateFile"},
315 {1, &IFileSystem::DeleteFile, "DeleteFile"}, 318 {1, &IFileSystem::DeleteFile, "DeleteFile"},
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index 8a2635ee4..9d3e0a658 100755
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -879,6 +879,10 @@ void Hid::AcquireNpadStyleSetUpdateEventHandle(Kernel::HLERequestContext& ctx) {
879 LOG_DEBUG(Service_HID, "called, npad_id={}, applet_resource_user_id={}, unknown={}", 879 LOG_DEBUG(Service_HID, "called, npad_id={}, applet_resource_user_id={}, unknown={}",
880 parameters.npad_id, parameters.applet_resource_user_id, parameters.unknown); 880 parameters.npad_id, parameters.applet_resource_user_id, parameters.unknown);
881 881
882 // Games expect this event to be signaled after calling this function
883 applet_resource->GetController<Controller_NPad>(HidController::NPad)
884 .SignalStyleSetChangedEvent(parameters.npad_id);
885
882 IPC::ResponseBuilder rb{ctx, 2, 1}; 886 IPC::ResponseBuilder rb{ctx, 2, 1};
883 rb.Push(ResultSuccess); 887 rb.Push(ResultSuccess);
884 rb.PushCopyObjects(applet_resource->GetController<Controller_NPad>(HidController::NPad) 888 rb.PushCopyObjects(applet_resource->GetController<Controller_NPad>(HidController::NPad)
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index ab3286db9..04eb0d6ea 100755
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -91,9 +91,11 @@ namespace Service {
91} 91}
92 92
93ServiceFrameworkBase::ServiceFrameworkBase(Core::System& system_, const char* service_name_, 93ServiceFrameworkBase::ServiceFrameworkBase(Core::System& system_, const char* service_name_,
94 u32 max_sessions_, InvokerFn* handler_invoker_) 94 bool create_service_thread_, u32 max_sessions_,
95 : SessionRequestHandler(system_.Kernel(), service_name_), system{system_}, 95 InvokerFn* handler_invoker_)
96 service_name{service_name_}, max_sessions{max_sessions_}, handler_invoker{handler_invoker_} {} 96 : SessionRequestHandler(system_.Kernel(), service_name_, create_service_thread_),
97 system{system_}, service_name{service_name_}, max_sessions{max_sessions_},
98 handler_invoker{handler_invoker_} {}
97 99
98ServiceFrameworkBase::~ServiceFrameworkBase() { 100ServiceFrameworkBase::~ServiceFrameworkBase() {
99 // Wait for other threads to release access before destroying 101 // Wait for other threads to release access before destroying
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h
index b9ab2c465..778b6da4e 100755
--- a/src/core/hle/service/service.h
+++ b/src/core/hle/service/service.h
@@ -114,7 +114,8 @@ private:
114 Kernel::HLERequestContext& ctx); 114 Kernel::HLERequestContext& ctx);
115 115
116 explicit ServiceFrameworkBase(Core::System& system_, const char* service_name_, 116 explicit ServiceFrameworkBase(Core::System& system_, const char* service_name_,
117 u32 max_sessions_, InvokerFn* handler_invoker_); 117 bool create_service_thread_, u32 max_sessions_,
118 InvokerFn* handler_invoker_);
118 ~ServiceFrameworkBase() override; 119 ~ServiceFrameworkBase() override;
119 120
120 void RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n); 121 void RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n);
@@ -176,14 +177,18 @@ protected:
176 /** 177 /**
177 * Initializes the handler with no functions installed. 178 * Initializes the handler with no functions installed.
178 * 179 *
179 * @param system_ The system context to construct this service under. 180 * @param system_ The system context to construct this service under.
180 * @param service_name_ Name of the service. 181 * @param service_name_ Name of the service.
181 * @param max_sessions_ Maximum number of sessions that can be 182 * @param create_service_thread_ Creates a service thread for this if true, otherwise use the
182 * connected to this service at the same time. 183 * default service thread.
184 * @param max_sessions_ Maximum number of sessions that can be connected to this service at the
185 * same time.
183 */ 186 */
184 explicit ServiceFramework(Core::System& system_, const char* service_name_, 187 explicit ServiceFramework(Core::System& system_, const char* service_name_,
188 bool create_service_thread_ = false,
185 u32 max_sessions_ = ServerSessionCountMax) 189 u32 max_sessions_ = ServerSessionCountMax)
186 : ServiceFrameworkBase(system_, service_name_, max_sessions_, Invoker) {} 190 : ServiceFrameworkBase(system_, service_name_, create_service_thread_, max_sessions_,
191 Invoker) {}
187 192
188 /// Registers handlers in the service. 193 /// Registers handlers in the service.
189 template <std::size_t N> 194 template <std::size_t N>
diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp
index 695a1faa6..5233e5b33 100755
--- a/src/core/hle/service/sm/sm.cpp
+++ b/src/core/hle/service/sm/sm.cpp
@@ -206,7 +206,7 @@ void SM::UnregisterService(Kernel::HLERequestContext& ctx) {
206} 206}
207 207
208SM::SM(ServiceManager& service_manager_, Core::System& system_) 208SM::SM(ServiceManager& service_manager_, Core::System& system_)
209 : ServiceFramework{system_, "sm:", 4}, 209 : ServiceFramework{system_, "sm:", false /*create_service_thread*/, 4},
210 service_manager{service_manager_}, kernel{system_.Kernel()} { 210 service_manager{service_manager_}, kernel{system_.Kernel()} {
211 RegisterHandlers({ 211 RegisterHandlers({
212 {0, &SM::Initialize, "Initialize"}, 212 {0, &SM::Initialize, "Initialize"},
diff --git a/src/core/hle/service/sockets/bsd.cpp b/src/core/hle/service/sockets/bsd.cpp
index fc93fb743..3970879c8 100755
--- a/src/core/hle/service/sockets/bsd.cpp
+++ b/src/core/hle/service/sockets/bsd.cpp
@@ -837,7 +837,8 @@ void BSD::BuildErrnoResponse(Kernel::HLERequestContext& ctx, Errno bsd_errno) co
837 rb.PushEnum(bsd_errno); 837 rb.PushEnum(bsd_errno);
838} 838}
839 839
840BSD::BSD(Core::System& system_, const char* name) : ServiceFramework{system_, name} { 840BSD::BSD(Core::System& system_, const char* name)
841 : ServiceFramework{system_, name, true /*create_service_thread*/} {
841 // clang-format off 842 // clang-format off
842 static const FunctionInfo functions[] = { 843 static const FunctionInfo functions[] = {
843 {0, &BSD::RegisterClient, "RegisterClient"}, 844 {0, &BSD::RegisterClient, "RegisterClient"},
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp
index 430cbc546..3284de519 100755
--- a/src/core/hle/service/vi/vi.cpp
+++ b/src/core/hle/service/vi/vi.cpp
@@ -77,7 +77,8 @@ static_assert(sizeof(NativeWindow) == 0x28, "NativeWindow has wrong size");
77class IHOSBinderDriver final : public ServiceFramework<IHOSBinderDriver> { 77class IHOSBinderDriver final : public ServiceFramework<IHOSBinderDriver> {
78public: 78public:
79 explicit IHOSBinderDriver(Core::System& system_, NVFlinger::HosBinderDriverServer& server_) 79 explicit IHOSBinderDriver(Core::System& system_, NVFlinger::HosBinderDriverServer& server_)
80 : ServiceFramework{system_, "IHOSBinderDriver"}, server(server_) { 80 : ServiceFramework{system_, "IHOSBinderDriver", true /*create_service_thread*/},
81 server(server_) {
81 static const FunctionInfo functions[] = { 82 static const FunctionInfo functions[] = {
82 {0, &IHOSBinderDriver::TransactParcel, "TransactParcel"}, 83 {0, &IHOSBinderDriver::TransactParcel, "TransactParcel"},
83 {1, &IHOSBinderDriver::AdjustRefcount, "AdjustRefcount"}, 84 {1, &IHOSBinderDriver::AdjustRefcount, "AdjustRefcount"},