From e86a7e36912b6f3fc64a594338d3c1ac768e3bb8 Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 29 Jan 2021 22:48:06 -0800 Subject: [PATCH 01/10] hle: kernel: Rename ReadableEvent to KReadableEvent. --- src/core/CMakeLists.txt | 4 ++-- src/core/hle/kernel/hle_ipc.cpp | 2 +- src/core/hle/kernel/hle_ipc.h | 2 +- .../{readable_event.cpp => k_readable_event.cpp} | 14 +++++++------- .../{readable_event.h => k_readable_event.h} | 6 +++--- src/core/hle/kernel/svc.cpp | 6 +++--- src/core/hle/kernel/writable_event.cpp | 6 +++--- src/core/hle/kernel/writable_event.h | 10 +++++----- src/core/hle/service/am/am.cpp | 6 +++--- src/core/hle/service/am/am.h | 4 ++-- src/core/hle/service/am/applets/applets.cpp | 8 ++++---- src/core/hle/service/am/applets/applets.h | 6 +++--- src/core/hle/service/aoc/aoc_u.cpp | 2 +- src/core/hle/service/audio/audout_u.cpp | 2 +- src/core/hle/service/audio/audren_u.cpp | 2 +- src/core/hle/service/bcat/backend/backend.cpp | 2 +- src/core/hle/service/bcat/backend/backend.h | 4 ++-- src/core/hle/service/bcat/module.cpp | 6 +++--- src/core/hle/service/btdrv/btdrv.cpp | 2 +- src/core/hle/service/btm/btm.cpp | 2 +- src/core/hle/service/friend/friend.cpp | 2 +- src/core/hle/service/hid/controllers/npad.cpp | 5 +++-- src/core/hle/service/hid/controllers/npad.h | 2 +- src/core/hle/service/hid/hid.cpp | 2 +- src/core/hle/service/nfp/nfp.cpp | 4 ++-- src/core/hle/service/nfp/nfp.h | 4 ++-- src/core/hle/service/nifm/nifm.cpp | 2 +- src/core/hle/service/nim/nim.cpp | 2 +- src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp | 2 +- src/core/hle/service/nvdrv/interface.cpp | 2 +- src/core/hle/service/nvdrv/nvdrv.cpp | 4 ++-- src/core/hle/service/nvdrv/nvdrv.h | 2 +- src/core/hle/service/nvflinger/buffer_queue.cpp | 4 ++-- src/core/hle/service/nvflinger/buffer_queue.h | 2 +- src/core/hle/service/nvflinger/nvflinger.cpp | 4 ++-- src/core/hle/service/nvflinger/nvflinger.h | 4 ++-- src/core/hle/service/ptm/psm.cpp | 2 +- src/core/hle/service/vi/display/vi_display.cpp | 4 ++-- src/core/hle/service/vi/display/vi_display.h | 2 +- src/core/hle/service/vi/vi.cpp | 2 +- src/yuzu/debugger/wait_tree.cpp | 6 +++--- src/yuzu/debugger/wait_tree.h | 4 ++-- 42 files changed, 82 insertions(+), 81 deletions(-) rename src/core/hle/kernel/{readable_event.cpp => k_readable_event.cpp} (74%) rename src/core/hle/kernel/{readable_event.h => k_readable_event.h} (89%) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 0ee02c81dc..330cab52c6 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -164,6 +164,8 @@ add_library(core STATIC hle/kernel/k_light_lock.cpp hle/kernel/k_light_lock.h hle/kernel/k_priority_queue.h + hle/kernel/k_readable_event.cpp + hle/kernel/k_readable_event.h hle/kernel/k_resource_limit.cpp hle/kernel/k_resource_limit.h hle/kernel/k_scheduler.cpp @@ -204,8 +206,6 @@ add_library(core STATIC hle/kernel/process.h hle/kernel/process_capability.cpp hle/kernel/process_capability.h - hle/kernel/readable_event.cpp - hle/kernel/readable_event.h hle/kernel/server_port.cpp hle/kernel/server_port.h hle/kernel/server_session.cpp diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index c7b10ca7af..93b9f793ea 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp @@ -17,13 +17,13 @@ #include "core/hle/kernel/errors.h" #include "core/hle/kernel/handle_table.h" #include "core/hle/kernel/hle_ipc.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_scheduler.h" #include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h" #include "core/hle/kernel/k_thread.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/object.h" #include "core/hle/kernel/process.h" -#include "core/hle/kernel/readable_event.h" #include "core/hle/kernel/server_session.h" #include "core/hle/kernel/time_manager.h" #include "core/hle/kernel/writable_event.h" diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index 9f764c79a9..89ae2a3292 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h @@ -41,7 +41,7 @@ class KernelCore; class Process; class ServerSession; class KThread; -class ReadableEvent; +class KReadableEvent; class WritableEvent; enum class ThreadWakeupReason; diff --git a/src/core/hle/kernel/readable_event.cpp b/src/core/hle/kernel/k_readable_event.cpp similarity index 74% rename from src/core/hle/kernel/readable_event.cpp rename to src/core/hle/kernel/k_readable_event.cpp index 596d014796..e9e191bc62 100644 --- a/src/core/hle/kernel/readable_event.cpp +++ b/src/core/hle/kernel/k_readable_event.cpp @@ -6,18 +6,18 @@ #include "common/assert.h" #include "common/logging/log.h" #include "core/hle/kernel/errors.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_scheduler.h" #include "core/hle/kernel/k_thread.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/object.h" -#include "core/hle/kernel/readable_event.h" namespace Kernel { -ReadableEvent::ReadableEvent(KernelCore& kernel) : KSynchronizationObject{kernel} {} -ReadableEvent::~ReadableEvent() = default; +KReadableEvent::KReadableEvent(KernelCore& kernel) : KSynchronizationObject{kernel} {} +KReadableEvent::~KReadableEvent() = default; -void ReadableEvent::Signal() { +void KReadableEvent::Signal() { if (is_signaled) { return; } @@ -26,17 +26,17 @@ void ReadableEvent::Signal() { NotifyAvailable(); } -bool ReadableEvent::IsSignaled() const { +bool KReadableEvent::IsSignaled() const { ASSERT(kernel.GlobalSchedulerContext().IsLocked()); return is_signaled; } -void ReadableEvent::Clear() { +void KReadableEvent::Clear() { is_signaled = false; } -ResultCode ReadableEvent::Reset() { +ResultCode KReadableEvent::Reset() { KScopedSchedulerLock lock(kernel); if (!is_signaled) { LOG_TRACE(Kernel, "Handle is not signaled! object_id={}, object_type={}, object_name={}", diff --git a/src/core/hle/kernel/readable_event.h b/src/core/hle/kernel/k_readable_event.h similarity index 89% rename from src/core/hle/kernel/readable_event.h rename to src/core/hle/kernel/k_readable_event.h index 2195710c20..50dfc60d3d 100644 --- a/src/core/hle/kernel/readable_event.h +++ b/src/core/hle/kernel/k_readable_event.h @@ -14,11 +14,11 @@ namespace Kernel { class KernelCore; class WritableEvent; -class ReadableEvent final : public KSynchronizationObject { +class KReadableEvent final : public KSynchronizationObject { friend class WritableEvent; public: - ~ReadableEvent() override; + ~KReadableEvent() override; std::string GetTypeName() const override { return "ReadableEvent"; @@ -50,7 +50,7 @@ public: void Finalize() override {} private: - explicit ReadableEvent(KernelCore& kernel); + explicit KReadableEvent(KernelCore& kernel); bool is_signaled{}; std::string name; ///< Name of event (optional) diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 74eb901002..1d2a2c321b 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -26,6 +26,7 @@ #include "core/hle/kernel/handle_table.h" #include "core/hle/kernel/k_address_arbiter.h" #include "core/hle/kernel/k_condition_variable.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_resource_limit.h" #include "core/hle/kernel/k_scheduler.h" #include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h" @@ -37,7 +38,6 @@ #include "core/hle/kernel/memory/page_table.h" #include "core/hle/kernel/physical_core.h" #include "core/hle/kernel/process.h" -#include "core/hle/kernel/readable_event.h" #include "core/hle/kernel/shared_memory.h" #include "core/hle/kernel/svc.h" #include "core/hle/kernel/svc_results.h" @@ -1727,7 +1727,7 @@ static ResultCode ResetSignal(Core::System& system, Handle handle) { const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); - auto event = handle_table.Get(handle); + auto event = handle_table.Get(handle); if (event) { return event->Reset(); } @@ -1909,7 +1909,7 @@ static ResultCode ClearEvent(Core::System& system, Handle handle) { return RESULT_SUCCESS; } - auto readable_event = handle_table.Get(handle); + auto readable_event = handle_table.Get(handle); if (readable_event) { readable_event->Clear(); return RESULT_SUCCESS; diff --git a/src/core/hle/kernel/writable_event.cpp b/src/core/hle/kernel/writable_event.cpp index 142212ee48..0d261e6e84 100644 --- a/src/core/hle/kernel/writable_event.cpp +++ b/src/core/hle/kernel/writable_event.cpp @@ -4,10 +4,10 @@ #include #include "common/assert.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_thread.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/object.h" -#include "core/hle/kernel/readable_event.h" #include "core/hle/kernel/writable_event.h" namespace Kernel { @@ -17,7 +17,7 @@ WritableEvent::~WritableEvent() = default; EventPair WritableEvent::CreateEventPair(KernelCore& kernel, std::string name) { std::shared_ptr writable_event(new WritableEvent(kernel)); - std::shared_ptr readable_event(new ReadableEvent(kernel)); + std::shared_ptr readable_event(new KReadableEvent(kernel)); writable_event->name = name + ":Writable"; writable_event->readable = readable_event; @@ -26,7 +26,7 @@ EventPair WritableEvent::CreateEventPair(KernelCore& kernel, std::string name) { return {std::move(readable_event), std::move(writable_event)}; } -std::shared_ptr WritableEvent::GetReadableEvent() const { +std::shared_ptr WritableEvent::GetReadableEvent() const { return readable; } diff --git a/src/core/hle/kernel/writable_event.h b/src/core/hle/kernel/writable_event.h index 467eb2c212..b288267c51 100644 --- a/src/core/hle/kernel/writable_event.h +++ b/src/core/hle/kernel/writable_event.h @@ -1,4 +1,4 @@ -// Copyright 2014 Citra Emulator Project +// Copyright 2021 yuzu Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. @@ -11,11 +11,11 @@ namespace Kernel { class KernelCore; -class ReadableEvent; +class KReadableEvent; class WritableEvent; struct EventPair { - std::shared_ptr readable; + std::shared_ptr readable; std::shared_ptr writable; }; @@ -42,7 +42,7 @@ public: return HANDLE_TYPE; } - std::shared_ptr GetReadableEvent() const; + std::shared_ptr GetReadableEvent() const; void Signal(); void Clear(); @@ -52,7 +52,7 @@ public: private: explicit WritableEvent(KernelCore& kernel); - std::shared_ptr readable; + std::shared_ptr readable; std::string name; ///< Name of event (optional) }; diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 07a7555994..8167bd89b0 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -13,9 +13,9 @@ #include "core/file_sys/registered_cache.h" #include "core/file_sys/savedata_factory.h" #include "core/hle/ipc_helpers.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/process.h" -#include "core/hle/kernel/readable_event.h" #include "core/hle/kernel/transfer_memory.h" #include "core/hle/kernel/writable_event.h" #include "core/hle/service/acc/profile_manager.h" @@ -567,11 +567,11 @@ AppletMessageQueue::AppletMessageQueue(Kernel::KernelCore& kernel) { AppletMessageQueue::~AppletMessageQueue() = default; -const std::shared_ptr& AppletMessageQueue::GetMessageReceiveEvent() const { +const std::shared_ptr& AppletMessageQueue::GetMessageReceiveEvent() const { return on_new_message.readable; } -const std::shared_ptr& AppletMessageQueue::GetOperationModeChangedEvent() +const std::shared_ptr& AppletMessageQueue::GetOperationModeChangedEvent() const { return on_operation_mode_changed.readable; } diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index 154a48710f..ff0510f36f 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -55,8 +55,8 @@ public: explicit AppletMessageQueue(Kernel::KernelCore& kernel); ~AppletMessageQueue(); - const std::shared_ptr& GetMessageReceiveEvent() const; - const std::shared_ptr& GetOperationModeChangedEvent() const; + const std::shared_ptr& GetMessageReceiveEvent() const; + const std::shared_ptr& GetOperationModeChangedEvent() const; void PushMessage(AppletMessage msg); AppletMessage PopMessage(); std::size_t GetMessageCount() const; diff --git a/src/core/hle/service/am/applets/applets.cpp b/src/core/hle/service/am/applets/applets.cpp index 08676c3fce..ac2f3f43a0 100644 --- a/src/core/hle/service/am/applets/applets.cpp +++ b/src/core/hle/service/am/applets/applets.cpp @@ -11,7 +11,7 @@ #include "core/frontend/applets/profile_select.h" #include "core/frontend/applets/software_keyboard.h" #include "core/frontend/applets/web_browser.h" -#include "core/hle/kernel/readable_event.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/server_session.h" #include "core/hle/kernel/writable_event.h" #include "core/hle/service/am/am.h" @@ -112,15 +112,15 @@ void AppletDataBroker::SignalStateChanged() const { state_changed_event.writable->Signal(); } -std::shared_ptr AppletDataBroker::GetNormalDataEvent() const { +std::shared_ptr AppletDataBroker::GetNormalDataEvent() const { return pop_out_data_event.readable; } -std::shared_ptr AppletDataBroker::GetInteractiveDataEvent() const { +std::shared_ptr AppletDataBroker::GetInteractiveDataEvent() const { return pop_interactive_out_data_event.readable; } -std::shared_ptr AppletDataBroker::GetStateChangedEvent() const { +std::shared_ptr AppletDataBroker::GetStateChangedEvent() const { return state_changed_event.readable; } diff --git a/src/core/hle/service/am/applets/applets.h b/src/core/hle/service/am/applets/applets.h index 4fd792c056..af0ad8346f 100644 --- a/src/core/hle/service/am/applets/applets.h +++ b/src/core/hle/service/am/applets/applets.h @@ -87,9 +87,9 @@ public: void SignalStateChanged() const; - std::shared_ptr GetNormalDataEvent() const; - std::shared_ptr GetInteractiveDataEvent() const; - std::shared_ptr GetStateChangedEvent() const; + std::shared_ptr GetNormalDataEvent() const; + std::shared_ptr GetInteractiveDataEvent() const; + std::shared_ptr GetStateChangedEvent() const; private: // Queues are named from applet's perspective diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp index 23e28565b7..d63bb2a044 100644 --- a/src/core/hle/service/aoc/aoc_u.cpp +++ b/src/core/hle/service/aoc/aoc_u.cpp @@ -14,9 +14,9 @@ #include "core/file_sys/patch_manager.h" #include "core/file_sys/registered_cache.h" #include "core/hle/ipc_helpers.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/process.h" -#include "core/hle/kernel/readable_event.h" #include "core/hle/kernel/writable_event.h" #include "core/hle/service/aoc/aoc_u.h" #include "core/loader/loader.h" diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp index 273a462657..b4c8e5cf49 100644 --- a/src/core/hle/service/audio/audout_u.cpp +++ b/src/core/hle/service/audio/audout_u.cpp @@ -14,8 +14,8 @@ #include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/hle_ipc.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/readable_event.h" #include "core/hle/kernel/writable_event.h" #include "core/hle/service/audio/audout_u.h" #include "core/hle/service/audio/errors.h" diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index c5c22d0537..dee0df5b6e 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp @@ -16,8 +16,8 @@ #include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/hle_ipc.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/readable_event.h" #include "core/hle/kernel/writable_event.h" #include "core/hle/service/audio/audren_u.h" #include "core/hle/service/audio/errors.h" diff --git a/src/core/hle/service/bcat/backend/backend.cpp b/src/core/hle/service/bcat/backend/backend.cpp index 174388445a..ebc18c1236 100644 --- a/src/core/hle/service/bcat/backend/backend.cpp +++ b/src/core/hle/service/bcat/backend/backend.cpp @@ -16,7 +16,7 @@ ProgressServiceBackend::ProgressServiceBackend(Kernel::KernelCore& kernel, kernel, std::string("ProgressServiceBackend:UpdateEvent:").append(event_name)); } -std::shared_ptr ProgressServiceBackend::GetEvent() const { +std::shared_ptr ProgressServiceBackend::GetEvent() const { return event.readable; } diff --git a/src/core/hle/service/bcat/backend/backend.h b/src/core/hle/service/bcat/backend/backend.h index 48bbbe66f9..fb398bd17a 100644 --- a/src/core/hle/service/bcat/backend/backend.h +++ b/src/core/hle/service/bcat/backend/backend.h @@ -11,7 +11,7 @@ #include "common/common_types.h" #include "core/file_sys/vfs_types.h" -#include "core/hle/kernel/readable_event.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/writable_event.h" #include "core/hle/result.h" @@ -98,7 +98,7 @@ public: private: explicit ProgressServiceBackend(Kernel::KernelCore& kernel, std::string_view event_name); - std::shared_ptr GetEvent() const; + std::shared_ptr GetEvent() const; DeliveryCacheProgressImpl& GetImpl(); void SignalUpdate() const; diff --git a/src/core/hle/service/bcat/module.cpp b/src/core/hle/service/bcat/module.cpp index b8696a395e..d7a77185f5 100644 --- a/src/core/hle/service/bcat/module.cpp +++ b/src/core/hle/service/bcat/module.cpp @@ -11,8 +11,8 @@ #include "core/core.h" #include "core/file_sys/vfs.h" #include "core/hle/ipc_helpers.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/process.h" -#include "core/hle/kernel/readable_event.h" #include "core/hle/kernel/writable_event.h" #include "core/hle/service/bcat/backend/backend.h" #include "core/hle/service/bcat/bcat.h" @@ -89,7 +89,7 @@ struct DeliveryCacheDirectoryEntry { class IDeliveryCacheProgressService final : public ServiceFramework { public: explicit IDeliveryCacheProgressService(Core::System& system_, - std::shared_ptr event_, + std::shared_ptr event_, const DeliveryCacheProgressImpl& impl_) : ServiceFramework{system_, "IDeliveryCacheProgressService"}, event{std::move(event_)}, impl{impl_} { @@ -121,7 +121,7 @@ private: rb.Push(RESULT_SUCCESS); } - std::shared_ptr event; + std::shared_ptr event; const DeliveryCacheProgressImpl& impl; }; diff --git a/src/core/hle/service/btdrv/btdrv.cpp b/src/core/hle/service/btdrv/btdrv.cpp index 2de86f1f1e..908d020e1d 100644 --- a/src/core/hle/service/btdrv/btdrv.cpp +++ b/src/core/hle/service/btdrv/btdrv.cpp @@ -6,8 +6,8 @@ #include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/hle_ipc.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/readable_event.h" #include "core/hle/kernel/writable_event.h" #include "core/hle/service/btdrv/btdrv.h" #include "core/hle/service/service.h" diff --git a/src/core/hle/service/btm/btm.cpp b/src/core/hle/service/btm/btm.cpp index 38b55300eb..9ec4235a21 100644 --- a/src/core/hle/service/btm/btm.cpp +++ b/src/core/hle/service/btm/btm.cpp @@ -8,8 +8,8 @@ #include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/hle_ipc.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/readable_event.h" #include "core/hle/kernel/writable_event.h" #include "core/hle/service/btm/btm.h" #include "core/hle/service/service.h" diff --git a/src/core/hle/service/friend/friend.cpp b/src/core/hle/service/friend/friend.cpp index c5b053c31b..5513d3adf4 100644 --- a/src/core/hle/service/friend/friend.cpp +++ b/src/core/hle/service/friend/friend.cpp @@ -7,7 +7,7 @@ #include "common/uuid.h" #include "core/core.h" #include "core/hle/ipc_helpers.h" -#include "core/hle/kernel/readable_event.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/writable_event.h" #include "core/hle/service/friend/errors.h" #include "core/hle/service/friend/friend.h" diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 0c227b1350..4c08ca2ca4 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp @@ -12,8 +12,8 @@ #include "core/core.h" #include "core/core_timing.h" #include "core/frontend/input.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/readable_event.h" #include "core/hle/kernel/writable_event.h" #include "core/hle/service/hid/controllers/npad.h" #include "core/settings.h" @@ -872,7 +872,8 @@ bool Controller_NPad::IsVibrationDeviceMounted(const DeviceHandle& vibration_dev return vibration_devices_mounted[npad_index][device_index]; } -std::shared_ptr Controller_NPad::GetStyleSetChangedEvent(u32 npad_id) const { +std::shared_ptr Controller_NPad::GetStyleSetChangedEvent( + u32 npad_id) const { const auto& styleset_event = styleset_changed_events[NPadIdToIndex(npad_id)]; return styleset_event.readable; } diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 2e13922b94..944970766d 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h @@ -187,7 +187,7 @@ public: bool IsVibrationDeviceMounted(const DeviceHandle& vibration_device_handle) const; - std::shared_ptr GetStyleSetChangedEvent(u32 npad_id) const; + std::shared_ptr GetStyleSetChangedEvent(u32 npad_id) const; void SignalStyleSetChangedEvent(u32 npad_id) const; // Adds a new controller at an index. diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 4cee4838c0..ee12d8e19c 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -14,8 +14,8 @@ #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/client_port.h" #include "core/hle/kernel/client_session.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/readable_event.h" #include "core/hle/kernel/shared_memory.h" #include "core/hle/kernel/writable_event.h" #include "core/hle/service/hid/errors.h" diff --git a/src/core/hle/service/nfp/nfp.cpp b/src/core/hle/service/nfp/nfp.cpp index a515fdc60d..173ab341d1 100644 --- a/src/core/hle/service/nfp/nfp.cpp +++ b/src/core/hle/service/nfp/nfp.cpp @@ -8,9 +8,9 @@ #include "common/logging/log.h" #include "core/core.h" #include "core/hle/ipc_helpers.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_thread.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/readable_event.h" #include "core/hle/kernel/writable_event.h" #include "core/hle/lock.h" #include "core/hle/service/nfp/nfp.h" @@ -340,7 +340,7 @@ bool Module::Interface::LoadAmiibo(const std::vector& buffer) { return true; } -const std::shared_ptr& Module::Interface::GetNFCEvent() const { +const std::shared_ptr& Module::Interface::GetNFCEvent() const { return nfc_tag_load.readable; } diff --git a/src/core/hle/service/nfp/nfp.h b/src/core/hle/service/nfp/nfp.h index 295de535bc..de510ff246 100644 --- a/src/core/hle/service/nfp/nfp.h +++ b/src/core/hle/service/nfp/nfp.h @@ -6,7 +6,7 @@ #include #include -#include "core/hle/kernel/readable_event.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/writable_event.h" #include "core/hle/service/service.h" @@ -35,7 +35,7 @@ public: void CreateUserInterface(Kernel::HLERequestContext& ctx); bool LoadAmiibo(const std::vector& buffer); - const std::shared_ptr& GetNFCEvent() const; + const std::shared_ptr& GetNFCEvent() const; const AmiiboFile& GetAmiiboBuffer() const; private: diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp index 8372e170c3..0a09c41ff3 100644 --- a/src/core/hle/service/nifm/nifm.cpp +++ b/src/core/hle/service/nifm/nifm.cpp @@ -4,8 +4,8 @@ #include "core/core.h" #include "core/hle/ipc_helpers.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/readable_event.h" #include "core/hle/kernel/writable_event.h" #include "core/hle/service/nifm/nifm.h" #include "core/hle/service/service.h" diff --git a/src/core/hle/service/nim/nim.cpp b/src/core/hle/service/nim/nim.cpp index d16223064e..bb681f0c7e 100644 --- a/src/core/hle/service/nim/nim.cpp +++ b/src/core/hle/service/nim/nim.cpp @@ -6,8 +6,8 @@ #include #include "core/core.h" #include "core/hle/ipc_helpers.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/readable_event.h" #include "core/hle/kernel/writable_event.h" #include "core/hle/service/nim/nim.h" #include "core/hle/service/service.h" diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp index 060599bab8..1fd5504a81 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp @@ -8,7 +8,7 @@ #include "common/assert.h" #include "common/logging/log.h" #include "core/core.h" -#include "core/hle/kernel/readable_event.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/writable_event.h" #include "core/hle/service/nvdrv/devices/nvhost_ctrl.h" #include "video_core/gpu.h" diff --git a/src/core/hle/service/nvdrv/interface.cpp b/src/core/hle/service/nvdrv/interface.cpp index 1328b64d0b..187501be8e 100644 --- a/src/core/hle/service/nvdrv/interface.cpp +++ b/src/core/hle/service/nvdrv/interface.cpp @@ -6,9 +6,9 @@ #include "common/logging/log.h" #include "core/core.h" #include "core/hle/ipc_helpers.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_thread.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/readable_event.h" #include "core/hle/kernel/writable_event.h" #include "core/hle/service/nvdrv/interface.h" #include "core/hle/service/nvdrv/nvdata.h" diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp index 620c187282..caeab0bd21 100644 --- a/src/core/hle/service/nvdrv/nvdrv.cpp +++ b/src/core/hle/service/nvdrv/nvdrv.cpp @@ -7,7 +7,7 @@ #include #include "core/core.h" #include "core/hle/ipc_helpers.h" -#include "core/hle/kernel/readable_event.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/writable_event.h" #include "core/hle/service/nvdrv/devices/nvdevice.h" #include "core/hle/service/nvdrv/devices/nvdisp_disp0.h" @@ -171,7 +171,7 @@ void Module::SignalSyncpt(const u32 syncpoint_id, const u32 value) { } } -std::shared_ptr Module::GetEvent(const u32 event_id) const { +std::shared_ptr Module::GetEvent(const u32 event_id) const { return events_interface.events[event_id].event.readable; } diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h index 144e657e5f..8a75c92ff7 100644 --- a/src/core/hle/service/nvdrv/nvdrv.h +++ b/src/core/hle/service/nvdrv/nvdrv.h @@ -132,7 +132,7 @@ public: void SignalSyncpt(const u32 syncpoint_id, const u32 value); - std::shared_ptr GetEvent(u32 event_id) const; + std::shared_ptr GetEvent(u32 event_id) const; std::shared_ptr GetEventWriteable(u32 event_id) const; diff --git a/src/core/hle/service/nvflinger/buffer_queue.cpp b/src/core/hle/service/nvflinger/buffer_queue.cpp index 5578181a4f..b7fd75d574 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.cpp +++ b/src/core/hle/service/nvflinger/buffer_queue.cpp @@ -7,8 +7,8 @@ #include "common/assert.h" #include "common/logging/log.h" #include "core/core.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/readable_event.h" #include "core/hle/kernel/writable_event.h" #include "core/hle/service/nvflinger/buffer_queue.h" @@ -192,7 +192,7 @@ std::shared_ptr BufferQueue::GetWritableBufferWaitEvent() return buffer_wait_event.writable; } -std::shared_ptr BufferQueue::GetBufferWaitEvent() const { +std::shared_ptr BufferQueue::GetBufferWaitEvent() const { return buffer_wait_event.readable; } diff --git a/src/core/hle/service/nvflinger/buffer_queue.h b/src/core/hle/service/nvflinger/buffer_queue.h index ad7469277d..8386e42b13 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.h +++ b/src/core/hle/service/nvflinger/buffer_queue.h @@ -115,7 +115,7 @@ public: std::shared_ptr GetWritableBufferWaitEvent() const; - std::shared_ptr GetBufferWaitEvent() const; + std::shared_ptr GetBufferWaitEvent() const; private: BufferQueue(const BufferQueue&) = delete; diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index ceaa93d282..ac2906e5b5 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp @@ -14,8 +14,8 @@ #include "core/core_timing.h" #include "core/core_timing_util.h" #include "core/hardware_properties.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/readable_event.h" #include "core/hle/service/nvdrv/devices/nvdisp_disp0.h" #include "core/hle/service/nvdrv/nvdrv.h" #include "core/hle/service/nvflinger/buffer_queue.h" @@ -165,7 +165,7 @@ std::optional NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) co return layer->GetBufferQueue().GetId(); } -std::shared_ptr NVFlinger::FindVsyncEvent(u64 display_id) const { +std::shared_ptr NVFlinger::FindVsyncEvent(u64 display_id) const { const auto guard = Lock(); auto* const display = FindDisplay(display_id); diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h index c6765259f3..8ba9c64e34 100644 --- a/src/core/hle/service/nvflinger/nvflinger.h +++ b/src/core/hle/service/nvflinger/nvflinger.h @@ -26,7 +26,7 @@ struct EventType; } // namespace Core::Timing namespace Kernel { -class ReadableEvent; +class KReadableEvent; class WritableEvent; } // namespace Kernel @@ -72,7 +72,7 @@ public: /// Gets the vsync event for the specified display. /// /// If an invalid display ID is provided, then nullptr is returned. - [[nodiscard]] std::shared_ptr FindVsyncEvent(u64 display_id) const; + [[nodiscard]] std::shared_ptr FindVsyncEvent(u64 display_id) const; /// Obtains a buffer queue identified by the ID. [[nodiscard]] BufferQueue* FindBufferQueue(u32 id); diff --git a/src/core/hle/service/ptm/psm.cpp b/src/core/hle/service/ptm/psm.cpp index a7cfccda30..1035951936 100644 --- a/src/core/hle/service/ptm/psm.cpp +++ b/src/core/hle/service/ptm/psm.cpp @@ -7,8 +7,8 @@ #include "common/logging/log.h" #include "core/core.h" #include "core/hle/ipc_helpers.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/readable_event.h" #include "core/hle/kernel/writable_event.h" #include "core/hle/service/ptm/psm.h" #include "core/hle/service/service.h" diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp index 5a202ac812..a3fb26100b 100644 --- a/src/core/hle/service/vi/display/vi_display.cpp +++ b/src/core/hle/service/vi/display/vi_display.cpp @@ -9,7 +9,7 @@ #include "common/assert.h" #include "core/core.h" -#include "core/hle/kernel/readable_event.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/service/vi/display/vi_display.h" #include "core/hle/service/vi/layer/vi_layer.h" @@ -31,7 +31,7 @@ const Layer& Display::GetLayer(std::size_t index) const { return *layers.at(index); } -std::shared_ptr Display::GetVSyncEvent() const { +std::shared_ptr Display::GetVSyncEvent() const { return vsync_event.readable; } diff --git a/src/core/hle/service/vi/display/vi_display.h b/src/core/hle/service/vi/display/vi_display.h index a3855d8cd0..bf0d320d1a 100644 --- a/src/core/hle/service/vi/display/vi_display.h +++ b/src/core/hle/service/vi/display/vi_display.h @@ -58,7 +58,7 @@ public: const Layer& GetLayer(std::size_t index) const; /// Gets the readable vsync event. - std::shared_ptr GetVSyncEvent() const; + std::shared_ptr GetVSyncEvent() const; /// Signals the internal vsync event. void SignalVSyncEvent(); diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index f3de2c428d..c573d474e3 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -18,8 +18,8 @@ #include "common/swap.h" #include "core/core_timing.h" #include "core/hle/ipc_helpers.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_thread.h" -#include "core/hle/kernel/readable_event.h" #include "core/hle/kernel/writable_event.h" #include "core/hle/service/nvdrv/nvdata.h" #include "core/hle/service/nvdrv/nvdrv.h" diff --git a/src/yuzu/debugger/wait_tree.cpp b/src/yuzu/debugger/wait_tree.cpp index 0e5156dcc4..3bca6277b6 100644 --- a/src/yuzu/debugger/wait_tree.cpp +++ b/src/yuzu/debugger/wait_tree.cpp @@ -13,11 +13,11 @@ #include "core/arm/arm_interface.h" #include "core/core.h" #include "core/hle/kernel/handle_table.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_scheduler.h" #include "core/hle/kernel/k_synchronization_object.h" #include "core/hle/kernel/k_thread.h" #include "core/hle/kernel/process.h" -#include "core/hle/kernel/readable_event.h" #include "core/hle/kernel/svc_common.h" #include "core/hle/kernel/svc_types.h" #include "core/memory.h" @@ -193,7 +193,7 @@ std::unique_ptr WaitTreeSynchronizationObject::ma const Kernel::KSynchronizationObject& object) { switch (object.GetHandleType()) { case Kernel::HandleType::ReadableEvent: - return std::make_unique(static_cast(object)); + return std::make_unique(static_cast(object)); case Kernel::HandleType::Thread: return std::make_unique(static_cast(object)); default: @@ -373,7 +373,7 @@ std::vector> WaitTreeThread::GetChildren() const { return list; } -WaitTreeEvent::WaitTreeEvent(const Kernel::ReadableEvent& object) +WaitTreeEvent::WaitTreeEvent(const Kernel::KReadableEvent& object) : WaitTreeSynchronizationObject(object) {} WaitTreeEvent::~WaitTreeEvent() = default; diff --git a/src/yuzu/debugger/wait_tree.h b/src/yuzu/debugger/wait_tree.h index b202c5567c..3da2fdfd22 100644 --- a/src/yuzu/debugger/wait_tree.h +++ b/src/yuzu/debugger/wait_tree.h @@ -18,9 +18,9 @@ class EmuThread; namespace Kernel { class HandleTable; +class KReadableEvent; class KSynchronizationObject; class KThread; -class ReadableEvent; } // namespace Kernel class WaitTreeThread; @@ -142,7 +142,7 @@ public: class WaitTreeEvent : public WaitTreeSynchronizationObject { Q_OBJECT public: - explicit WaitTreeEvent(const Kernel::ReadableEvent& object); + explicit WaitTreeEvent(const Kernel::KReadableEvent& object); ~WaitTreeEvent() override; }; From 3f942c01f0d8c42837c49a164ed78f6410d62bda Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 29 Jan 2021 23:51:40 -0800 Subject: [PATCH 02/10] hle: kernel: Rename WritableEvent to KWritableEvent. --- src/core/CMakeLists.txt | 4 ++-- src/core/hle/kernel/hle_ipc.cpp | 2 +- src/core/hle/kernel/hle_ipc.h | 2 +- src/core/hle/kernel/k_readable_event.h | 4 ++-- .../{writable_event.cpp => k_writable_event.cpp} | 16 ++++++++-------- .../{writable_event.h => k_writable_event.h} | 10 +++++----- src/core/hle/kernel/svc.cpp | 8 ++++---- src/core/hle/service/am/am.cpp | 16 ++++++++-------- src/core/hle/service/am/am.h | 2 +- src/core/hle/service/am/applets/applets.cpp | 8 ++++---- src/core/hle/service/am/applets/applets.h | 2 +- src/core/hle/service/aoc/aoc_u.cpp | 6 +++--- src/core/hle/service/aoc/aoc_u.h | 2 +- src/core/hle/service/audio/audout_u.cpp | 4 ++-- src/core/hle/service/audio/audren_u.cpp | 10 +++++----- src/core/hle/service/bcat/backend/backend.cpp | 2 +- src/core/hle/service/bcat/backend/backend.h | 2 +- src/core/hle/service/bcat/module.cpp | 2 +- src/core/hle/service/btdrv/btdrv.cpp | 4 ++-- src/core/hle/service/btm/btm.cpp | 10 +++++----- src/core/hle/service/friend/friend.cpp | 4 ++-- src/core/hle/service/hid/controllers/npad.cpp | 4 ++-- src/core/hle/service/hid/controllers/npad.h | 2 +- src/core/hle/service/hid/hid.cpp | 2 +- src/core/hle/service/nfp/nfp.cpp | 8 ++++---- src/core/hle/service/nfp/nfp.h | 2 +- src/core/hle/service/nifm/nifm.cpp | 6 +++--- src/core/hle/service/nim/nim.cpp | 4 ++-- .../hle/service/nvdrv/devices/nvhost_ctrl.cpp | 2 +- src/core/hle/service/nvdrv/interface.cpp | 2 +- src/core/hle/service/nvdrv/interface.h | 2 +- src/core/hle/service/nvdrv/nvdrv.cpp | 6 +++--- src/core/hle/service/nvdrv/nvdrv.h | 4 ++-- src/core/hle/service/nvflinger/buffer_queue.cpp | 6 +++--- src/core/hle/service/nvflinger/buffer_queue.h | 4 ++-- src/core/hle/service/nvflinger/nvflinger.h | 2 +- src/core/hle/service/ptm/psm.cpp | 4 ++-- .../time/standard_user_system_clock_core.cpp | 4 ++-- .../time/standard_user_system_clock_core.h | 2 +- .../system_clock_context_update_callback.cpp | 4 ++-- .../time/system_clock_context_update_callback.h | 6 +++--- src/core/hle/service/vi/display/vi_display.cpp | 2 +- src/core/hle/service/vi/display/vi_display.h | 2 +- src/core/hle/service/vi/vi.cpp | 2 +- 44 files changed, 101 insertions(+), 101 deletions(-) rename src/core/hle/kernel/{writable_event.cpp => k_writable_event.cpp} (61%) rename src/core/hle/kernel/{writable_event.h => k_writable_event.h} (85%) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 330cab52c6..73ee48f4f6 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -178,6 +178,8 @@ add_library(core STATIC hle/kernel/k_thread.cpp hle/kernel/k_thread.h hle/kernel/k_thread_queue.h + hle/kernel/k_writable_event.cpp + hle/kernel/k_writable_event.h hle/kernel/kernel.cpp hle/kernel/kernel.h hle/kernel/memory/address_space_info.cpp @@ -226,8 +228,6 @@ add_library(core STATIC hle/kernel/time_manager.h hle/kernel/transfer_memory.cpp hle/kernel/transfer_memory.h - hle/kernel/writable_event.cpp - hle/kernel/writable_event.h hle/lock.cpp hle/lock.h hle/result.h diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index 93b9f793ea..7ec62cf184 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp @@ -21,12 +21,12 @@ #include "core/hle/kernel/k_scheduler.h" #include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h" #include "core/hle/kernel/k_thread.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/object.h" #include "core/hle/kernel/process.h" #include "core/hle/kernel/server_session.h" #include "core/hle/kernel/time_manager.h" -#include "core/hle/kernel/writable_event.h" #include "core/memory.h" namespace Kernel { diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index 89ae2a3292..9a769781b6 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h @@ -42,7 +42,7 @@ class Process; class ServerSession; class KThread; class KReadableEvent; -class WritableEvent; +class KWritableEvent; enum class ThreadWakeupReason; diff --git a/src/core/hle/kernel/k_readable_event.h b/src/core/hle/kernel/k_readable_event.h index 50dfc60d3d..39eedc4118 100644 --- a/src/core/hle/kernel/k_readable_event.h +++ b/src/core/hle/kernel/k_readable_event.h @@ -12,10 +12,10 @@ union ResultCode; namespace Kernel { class KernelCore; -class WritableEvent; +class KWritableEvent; class KReadableEvent final : public KSynchronizationObject { - friend class WritableEvent; + friend class KWritableEvent; public: ~KReadableEvent() override; diff --git a/src/core/hle/kernel/writable_event.cpp b/src/core/hle/kernel/k_writable_event.cpp similarity index 61% rename from src/core/hle/kernel/writable_event.cpp rename to src/core/hle/kernel/k_writable_event.cpp index 0d261e6e84..d2857b4c3a 100644 --- a/src/core/hle/kernel/writable_event.cpp +++ b/src/core/hle/kernel/k_writable_event.cpp @@ -6,17 +6,17 @@ #include "common/assert.h" #include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_thread.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/object.h" -#include "core/hle/kernel/writable_event.h" namespace Kernel { -WritableEvent::WritableEvent(KernelCore& kernel) : Object{kernel} {} -WritableEvent::~WritableEvent() = default; +KWritableEvent::KWritableEvent(KernelCore& kernel) : Object{kernel} {} +KWritableEvent::~KWritableEvent() = default; -EventPair WritableEvent::CreateEventPair(KernelCore& kernel, std::string name) { - std::shared_ptr writable_event(new WritableEvent(kernel)); +EventPair KWritableEvent::CreateEventPair(KernelCore& kernel, std::string name) { + std::shared_ptr writable_event(new KWritableEvent(kernel)); std::shared_ptr readable_event(new KReadableEvent(kernel)); writable_event->name = name + ":Writable"; @@ -26,15 +26,15 @@ EventPair WritableEvent::CreateEventPair(KernelCore& kernel, std::string name) { return {std::move(readable_event), std::move(writable_event)}; } -std::shared_ptr WritableEvent::GetReadableEvent() const { +std::shared_ptr KWritableEvent::GetReadableEvent() const { return readable; } -void WritableEvent::Signal() { +void KWritableEvent::Signal() { readable->Signal(); } -void WritableEvent::Clear() { +void KWritableEvent::Clear() { readable->Clear(); } diff --git a/src/core/hle/kernel/writable_event.h b/src/core/hle/kernel/k_writable_event.h similarity index 85% rename from src/core/hle/kernel/writable_event.h rename to src/core/hle/kernel/k_writable_event.h index b288267c51..ad5514b525 100644 --- a/src/core/hle/kernel/writable_event.h +++ b/src/core/hle/kernel/k_writable_event.h @@ -12,16 +12,16 @@ namespace Kernel { class KernelCore; class KReadableEvent; -class WritableEvent; +class KWritableEvent; struct EventPair { std::shared_ptr readable; - std::shared_ptr writable; + std::shared_ptr writable; }; -class WritableEvent final : public Object { +class KWritableEvent final : public Object { public: - ~WritableEvent() override; + ~KWritableEvent() override; /** * Creates an event @@ -50,7 +50,7 @@ public: void Finalize() override {} private: - explicit WritableEvent(KernelCore& kernel); + explicit KWritableEvent(KernelCore& kernel); std::shared_ptr readable; diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 1d2a2c321b..f94eecbb8e 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -32,6 +32,7 @@ #include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h" #include "core/hle/kernel/k_synchronization_object.h" #include "core/hle/kernel/k_thread.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/memory/memory_block.h" #include "core/hle/kernel/memory/memory_layout.h" @@ -45,7 +46,6 @@ #include "core/hle/kernel/svc_wrap.h" #include "core/hle/kernel/time_manager.h" #include "core/hle/kernel/transfer_memory.h" -#include "core/hle/kernel/writable_event.h" #include "core/hle/lock.h" #include "core/hle/result.h" #include "core/hle/service/service.h" @@ -1871,7 +1871,7 @@ static ResultCode CreateEvent(Core::System& system, Handle* write_handle, Handle auto& kernel = system.Kernel(); const auto [readable_event, writable_event] = - WritableEvent::CreateEventPair(kernel, "CreateEvent"); + KWritableEvent::CreateEventPair(kernel, "CreateEvent"); HandleTable& handle_table = kernel.CurrentProcess()->GetHandleTable(); @@ -1903,7 +1903,7 @@ static ResultCode ClearEvent(Core::System& system, Handle handle) { const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); - auto writable_event = handle_table.Get(handle); + auto writable_event = handle_table.Get(handle); if (writable_event) { writable_event->Clear(); return RESULT_SUCCESS; @@ -1927,7 +1927,7 @@ static ResultCode SignalEvent(Core::System& system, Handle handle) { LOG_DEBUG(Kernel_SVC, "called. Handle=0x{:08X}", handle); HandleTable& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); - auto writable_event = handle_table.Get(handle); + auto writable_event = handle_table.Get(handle); if (!writable_event) { LOG_ERROR(Kernel_SVC, "Non-existent writable event handle used (0x{:08X})", handle); diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 8167bd89b0..e1aa208baa 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -14,10 +14,10 @@ #include "core/file_sys/savedata_factory.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_readable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/process.h" #include "core/hle/kernel/transfer_memory.h" -#include "core/hle/kernel/writable_event.h" #include "core/hle/service/acc/profile_manager.h" #include "core/hle/service/am/am.h" #include "core/hle/service/am/applet_ae.h" @@ -304,14 +304,14 @@ ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nv auto& kernel = system.Kernel(); launchable_event = - Kernel::WritableEvent::CreateEventPair(kernel, "ISelfController:LaunchableEvent"); + Kernel::KWritableEvent::CreateEventPair(kernel, "ISelfController:LaunchableEvent"); // This event is created by AM on the first time GetAccumulatedSuspendedTickChangedEvent() is // called. Yuzu can just create it unconditionally, since it doesn't need to support multiple // ISelfControllers. The event is signaled on creation, and on transition from suspended -> not // suspended if the event has previously been created by a call to // GetAccumulatedSuspendedTickChangedEvent. - accumulated_suspended_tick_changed_event = Kernel::WritableEvent::CreateEventPair( + accumulated_suspended_tick_changed_event = Kernel::KWritableEvent::CreateEventPair( kernel, "ISelfController:AccumulatedSuspendedTickChangedEvent"); accumulated_suspended_tick_changed_event.writable->Signal(); } @@ -560,9 +560,9 @@ void ISelfController::GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequest AppletMessageQueue::AppletMessageQueue(Kernel::KernelCore& kernel) { on_new_message = - Kernel::WritableEvent::CreateEventPair(kernel, "AMMessageQueue:OnMessageReceived"); + Kernel::KWritableEvent::CreateEventPair(kernel, "AMMessageQueue:OnMessageReceived"); on_operation_mode_changed = - Kernel::WritableEvent::CreateEventPair(kernel, "AMMessageQueue:OperationModeChanged"); + Kernel::KWritableEvent::CreateEventPair(kernel, "AMMessageQueue:OperationModeChanged"); } AppletMessageQueue::~AppletMessageQueue() = default; @@ -1229,10 +1229,10 @@ IApplicationFunctions::IApplicationFunctions(Core::System& system_) RegisterHandlers(functions); auto& kernel = system.Kernel(); - gpu_error_detected_event = Kernel::WritableEvent::CreateEventPair( + gpu_error_detected_event = Kernel::KWritableEvent::CreateEventPair( kernel, "IApplicationFunctions:GpuErrorDetectedSystemEvent"); - friend_invitation_storage_channel_event = Kernel::WritableEvent::CreateEventPair( + friend_invitation_storage_channel_event = Kernel::KWritableEvent::CreateEventPair( kernel, "IApplicationFunctions:FriendInvitationStorageChannelEvent"); health_warning_disappeared_system_event = Kernel::WritableEvent::CreateEventPair( @@ -1693,7 +1693,7 @@ IHomeMenuFunctions::IHomeMenuFunctions(Core::System& system_) RegisterHandlers(functions); - pop_from_general_channel_event = Kernel::WritableEvent::CreateEventPair( + pop_from_general_channel_event = Kernel::KWritableEvent::CreateEventPair( system.Kernel(), "IHomeMenuFunctions:PopFromGeneralChannelEvent"); } diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index ff0510f36f..37d7b41de4 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -7,7 +7,7 @@ #include #include #include -#include "core/hle/kernel/writable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/service/service.h" namespace Kernel { diff --git a/src/core/hle/service/am/applets/applets.cpp b/src/core/hle/service/am/applets/applets.cpp index ac2f3f43a0..c96b455d32 100644 --- a/src/core/hle/service/am/applets/applets.cpp +++ b/src/core/hle/service/am/applets/applets.cpp @@ -12,8 +12,8 @@ #include "core/frontend/applets/software_keyboard.h" #include "core/frontend/applets/web_browser.h" #include "core/hle/kernel/k_readable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/server_session.h" -#include "core/hle/kernel/writable_event.h" #include "core/hle/service/am/am.h" #include "core/hle/service/am/applets/applets.h" #include "core/hle/service/am/applets/controller.h" @@ -27,10 +27,10 @@ namespace Service::AM::Applets { AppletDataBroker::AppletDataBroker(Kernel::KernelCore& kernel) { state_changed_event = - Kernel::WritableEvent::CreateEventPair(kernel, "ILibraryAppletAccessor:StateChangedEvent"); + Kernel::KWritableEvent::CreateEventPair(kernel, "ILibraryAppletAccessor:StateChangedEvent"); pop_out_data_event = - Kernel::WritableEvent::CreateEventPair(kernel, "ILibraryAppletAccessor:PopDataOutEvent"); - pop_interactive_out_data_event = Kernel::WritableEvent::CreateEventPair( + Kernel::KWritableEvent::CreateEventPair(kernel, "ILibraryAppletAccessor:PopDataOutEvent"); + pop_interactive_out_data_event = Kernel::KWritableEvent::CreateEventPair( kernel, "ILibraryAppletAccessor:PopInteractiveDataOutEvent"); } diff --git a/src/core/hle/service/am/applets/applets.h b/src/core/hle/service/am/applets/applets.h index af0ad8346f..7ebfb9bbd7 100644 --- a/src/core/hle/service/am/applets/applets.h +++ b/src/core/hle/service/am/applets/applets.h @@ -7,8 +7,8 @@ #include #include #include "common/swap.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/object.h" -#include "core/hle/kernel/writable_event.h" union ResultCode; diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp index d63bb2a044..334920c234 100644 --- a/src/core/hle/service/aoc/aoc_u.cpp +++ b/src/core/hle/service/aoc/aoc_u.cpp @@ -15,9 +15,9 @@ #include "core/file_sys/registered_cache.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_readable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/process.h" -#include "core/hle/kernel/writable_event.h" #include "core/hle/service/aoc/aoc_u.h" #include "core/loader/loader.h" #include "core/settings.h" @@ -62,7 +62,7 @@ public: RegisterHandlers(functions); - purchased_event = Kernel::WritableEvent::CreateEventPair( + purchased_event = Kernel::KWritableEvent::CreateEventPair( system.Kernel(), "IPurchaseEventManager:PurchasedEvent"); } @@ -125,7 +125,7 @@ AOC_U::AOC_U(Core::System& system_) auto& kernel = system.Kernel(); aoc_change_event = - Kernel::WritableEvent::CreateEventPair(kernel, "GetAddOnContentListChanged:Event"); + Kernel::KWritableEvent::CreateEventPair(kernel, "GetAddOnContentListChanged:Event"); } AOC_U::~AOC_U() = default; diff --git a/src/core/hle/service/aoc/aoc_u.h b/src/core/hle/service/aoc/aoc_u.h index 26ee51be07..594152de58 100644 --- a/src/core/hle/service/aoc/aoc_u.h +++ b/src/core/hle/service/aoc/aoc_u.h @@ -11,7 +11,7 @@ class System; } namespace Kernel { -class WritableEvent; +class KWritableEvent; } namespace Service::AOC { diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp index b4c8e5cf49..3c60ec43d5 100644 --- a/src/core/hle/service/audio/audout_u.cpp +++ b/src/core/hle/service/audio/audout_u.cpp @@ -15,8 +15,8 @@ #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/k_readable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/writable_event.h" #include "core/hle/service/audio/audout_u.h" #include "core/hle/service/audio/errors.h" #include "core/memory.h" @@ -67,7 +67,7 @@ public: // This is the event handle used to check if the audio buffer was released buffer_event = - Kernel::WritableEvent::CreateEventPair(system.Kernel(), "IAudioOutBufferReleased"); + Kernel::KWritableEvent::CreateEventPair(system.Kernel(), "IAudioOutBufferReleased"); stream = audio_core.OpenStream(system.CoreTiming(), audio_params.sample_rate, audio_params.channel_count, std::move(unique_name), [this] { diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index dee0df5b6e..aa50e73a9d 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp @@ -17,8 +17,8 @@ #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/k_readable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/writable_event.h" #include "core/hle/service/audio/audren_u.h" #include "core/hle/service/audio/errors.h" @@ -48,7 +48,7 @@ public: RegisterHandlers(functions); system_event = - Kernel::WritableEvent::CreateEventPair(system.Kernel(), "IAudioRenderer:SystemEvent"); + Kernel::KWritableEvent::CreateEventPair(system.Kernel(), "IAudioRenderer:SystemEvent"); renderer = std::make_unique( system.CoreTiming(), system.Memory(), audren_params, [this]() { @@ -188,15 +188,15 @@ public: auto& kernel = system.Kernel(); buffer_event = - Kernel::WritableEvent::CreateEventPair(kernel, "IAudioOutBufferReleasedEvent"); + Kernel::KWritableEvent::CreateEventPair(kernel, "IAudioOutBufferReleasedEvent"); // Should be similar to audio_output_device_switch_event - audio_input_device_switch_event = Kernel::WritableEvent::CreateEventPair( + audio_input_device_switch_event = Kernel::KWritableEvent::CreateEventPair( kernel, "IAudioDevice:AudioInputDeviceSwitchedEvent"); // Should only be signalled when an audio output device has been changed, example: speaker // to headset - audio_output_device_switch_event = Kernel::WritableEvent::CreateEventPair( + audio_output_device_switch_event = Kernel::KWritableEvent::CreateEventPair( kernel, "IAudioDevice:AudioOutputDeviceSwitchedEvent"); } diff --git a/src/core/hle/service/bcat/backend/backend.cpp b/src/core/hle/service/bcat/backend/backend.cpp index ebc18c1236..3b853e9e44 100644 --- a/src/core/hle/service/bcat/backend/backend.cpp +++ b/src/core/hle/service/bcat/backend/backend.cpp @@ -12,7 +12,7 @@ namespace Service::BCAT { ProgressServiceBackend::ProgressServiceBackend(Kernel::KernelCore& kernel, std::string_view event_name) { - event = Kernel::WritableEvent::CreateEventPair( + event = Kernel::KWritableEvent::CreateEventPair( kernel, std::string("ProgressServiceBackend:UpdateEvent:").append(event_name)); } diff --git a/src/core/hle/service/bcat/backend/backend.h b/src/core/hle/service/bcat/backend/backend.h index fb398bd17a..b190943ace 100644 --- a/src/core/hle/service/bcat/backend/backend.h +++ b/src/core/hle/service/bcat/backend/backend.h @@ -12,7 +12,7 @@ #include "common/common_types.h" #include "core/file_sys/vfs_types.h" #include "core/hle/kernel/k_readable_event.h" -#include "core/hle/kernel/writable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/result.h" namespace Core { diff --git a/src/core/hle/service/bcat/module.cpp b/src/core/hle/service/bcat/module.cpp index d7a77185f5..503109fdd8 100644 --- a/src/core/hle/service/bcat/module.cpp +++ b/src/core/hle/service/bcat/module.cpp @@ -12,8 +12,8 @@ #include "core/file_sys/vfs.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_readable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/process.h" -#include "core/hle/kernel/writable_event.h" #include "core/hle/service/bcat/backend/backend.h" #include "core/hle/service/bcat/bcat.h" #include "core/hle/service/bcat/module.h" diff --git a/src/core/hle/service/btdrv/btdrv.cpp b/src/core/hle/service/btdrv/btdrv.cpp index 908d020e1d..4c78cd0083 100644 --- a/src/core/hle/service/btdrv/btdrv.cpp +++ b/src/core/hle/service/btdrv/btdrv.cpp @@ -7,8 +7,8 @@ #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/k_readable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/writable_event.h" #include "core/hle/service/btdrv/btdrv.h" #include "core/hle/service/service.h" #include "core/hle/service/sm/sm.h" @@ -35,7 +35,7 @@ public: RegisterHandlers(functions); auto& kernel = system.Kernel(); - register_event = Kernel::WritableEvent::CreateEventPair(kernel, "BT:RegisterEvent"); + register_event = Kernel::KWritableEvent::CreateEventPair(kernel, "BT:RegisterEvent"); } private: diff --git a/src/core/hle/service/btm/btm.cpp b/src/core/hle/service/btm/btm.cpp index 9ec4235a21..3af51d6030 100644 --- a/src/core/hle/service/btm/btm.cpp +++ b/src/core/hle/service/btm/btm.cpp @@ -9,8 +9,8 @@ #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/k_readable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/writable_event.h" #include "core/hle/service/btm/btm.h" #include "core/hle/service/service.h" @@ -58,12 +58,12 @@ public: RegisterHandlers(functions); auto& kernel = system.Kernel(); - scan_event = Kernel::WritableEvent::CreateEventPair(kernel, "IBtmUserCore:ScanEvent"); + scan_event = Kernel::KWritableEvent::CreateEventPair(kernel, "IBtmUserCore:ScanEvent"); connection_event = - Kernel::WritableEvent::CreateEventPair(kernel, "IBtmUserCore:ConnectionEvent"); + Kernel::KWritableEvent::CreateEventPair(kernel, "IBtmUserCore:ConnectionEvent"); service_discovery = - Kernel::WritableEvent::CreateEventPair(kernel, "IBtmUserCore:Discovery"); - config_event = Kernel::WritableEvent::CreateEventPair(kernel, "IBtmUserCore:ConfigEvent"); + Kernel::KWritableEvent::CreateEventPair(kernel, "IBtmUserCore:Discovery"); + config_event = Kernel::KWritableEvent::CreateEventPair(kernel, "IBtmUserCore:ConfigEvent"); } private: diff --git a/src/core/hle/service/friend/friend.cpp b/src/core/hle/service/friend/friend.cpp index 5513d3adf4..fa6cc74ed0 100644 --- a/src/core/hle/service/friend/friend.cpp +++ b/src/core/hle/service/friend/friend.cpp @@ -8,7 +8,7 @@ #include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_readable_event.h" -#include "core/hle/kernel/writable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/service/friend/errors.h" #include "core/hle/service/friend/friend.h" #include "core/hle/service/friend/interface.h" @@ -183,7 +183,7 @@ public: RegisterHandlers(functions); - notification_event = Kernel::WritableEvent::CreateEventPair( + notification_event = Kernel::KWritableEvent::CreateEventPair( system.Kernel(), "INotificationService:NotifyEvent"); } diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 4c08ca2ca4..35f93da4f3 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp @@ -13,8 +13,8 @@ #include "core/core_timing.h" #include "core/frontend/input.h" #include "core/hle/kernel/k_readable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/writable_event.h" #include "core/hle/service/hid/controllers/npad.h" #include "core/settings.h" @@ -233,7 +233,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) { void Controller_NPad::OnInit() { auto& kernel = system.Kernel(); for (std::size_t i = 0; i < styleset_changed_events.size(); ++i) { - styleset_changed_events[i] = Kernel::WritableEvent::CreateEventPair( + styleset_changed_events[i] = Kernel::KWritableEvent::CreateEventPair( kernel, fmt::format("npad:NpadStyleSetChanged_{}", i)); } diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 944970766d..110b56cc4a 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h @@ -9,8 +9,8 @@ #include "common/bit_field.h" #include "common/common_types.h" #include "core/frontend/input.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/object.h" -#include "core/hle/kernel/writable_event.h" #include "core/hle/service/hid/controllers/controller_base.h" #include "core/settings.h" diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index ee12d8e19c..dda33f2b45 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -15,9 +15,9 @@ #include "core/hle/kernel/client_port.h" #include "core/hle/kernel/client_session.h" #include "core/hle/kernel/k_readable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/shared_memory.h" -#include "core/hle/kernel/writable_event.h" #include "core/hle/service/hid/errors.h" #include "core/hle/service/hid/hid.h" #include "core/hle/service/hid/irs.h" diff --git a/src/core/hle/service/nfp/nfp.cpp b/src/core/hle/service/nfp/nfp.cpp index 173ab341d1..0e53aa848e 100644 --- a/src/core/hle/service/nfp/nfp.cpp +++ b/src/core/hle/service/nfp/nfp.cpp @@ -10,8 +10,8 @@ #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_thread.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/writable_event.h" #include "core/hle/lock.h" #include "core/hle/service/nfp/nfp.h" #include "core/hle/service/nfp/nfp_user.h" @@ -25,7 +25,7 @@ Module::Interface::Interface(std::shared_ptr module_, Core::System& syst const char* name) : ServiceFramework{system_, name}, module{std::move(module_)} { auto& kernel = system.Kernel(); - nfc_tag_load = Kernel::WritableEvent::CreateEventPair(kernel, "IUser:NFCTagDetected"); + nfc_tag_load = Kernel::KWritableEvent::CreateEventPair(kernel, "IUser:NFCTagDetected"); } Module::Interface::~Interface() = default; @@ -64,9 +64,9 @@ public: RegisterHandlers(functions); auto& kernel = system.Kernel(); - deactivate_event = Kernel::WritableEvent::CreateEventPair(kernel, "IUser:DeactivateEvent"); + deactivate_event = Kernel::KWritableEvent::CreateEventPair(kernel, "IUser:DeactivateEvent"); availability_change_event = - Kernel::WritableEvent::CreateEventPair(kernel, "IUser:AvailabilityChangeEvent"); + Kernel::KWritableEvent::CreateEventPair(kernel, "IUser:AvailabilityChangeEvent"); } private: diff --git a/src/core/hle/service/nfp/nfp.h b/src/core/hle/service/nfp/nfp.h index de510ff246..9ed5ed0f7a 100644 --- a/src/core/hle/service/nfp/nfp.h +++ b/src/core/hle/service/nfp/nfp.h @@ -7,7 +7,7 @@ #include #include #include "core/hle/kernel/k_readable_event.h" -#include "core/hle/kernel/writable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/service/service.h" namespace Service::NFP { diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp index 0a09c41ff3..6cb778140c 100644 --- a/src/core/hle/service/nifm/nifm.cpp +++ b/src/core/hle/service/nifm/nifm.cpp @@ -5,8 +5,8 @@ #include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_readable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/writable_event.h" #include "core/hle/service/nifm/nifm.h" #include "core/hle/service/service.h" #include "core/network/network.h" @@ -158,8 +158,8 @@ public: RegisterHandlers(functions); auto& kernel = system.Kernel(); - event1 = Kernel::WritableEvent::CreateEventPair(kernel, "IRequest:Event1"); - event2 = Kernel::WritableEvent::CreateEventPair(kernel, "IRequest:Event2"); + event1 = Kernel::KWritableEvent::CreateEventPair(kernel, "IRequest:Event1"); + event2 = Kernel::KWritableEvent::CreateEventPair(kernel, "IRequest:Event2"); } private: diff --git a/src/core/hle/service/nim/nim.cpp b/src/core/hle/service/nim/nim.cpp index bb681f0c7e..f180221fe5 100644 --- a/src/core/hle/service/nim/nim.cpp +++ b/src/core/hle/service/nim/nim.cpp @@ -7,8 +7,8 @@ #include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_readable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/writable_event.h" #include "core/hle/service/nim/nim.h" #include "core/hle/service/service.h" #include "core/hle/service/sm/sm.h" @@ -301,7 +301,7 @@ public: RegisterHandlers(functions); auto& kernel = system.Kernel(); - finished_event = Kernel::WritableEvent::CreateEventPair( + finished_event = Kernel::KWritableEvent::CreateEventPair( kernel, "IEnsureNetworkClockAvailabilityService:FinishEvent"); } diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp index 1fd5504a81..695e2fb10e 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp @@ -9,7 +9,7 @@ #include "common/logging/log.h" #include "core/core.h" #include "core/hle/kernel/k_readable_event.h" -#include "core/hle/kernel/writable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/service/nvdrv/devices/nvhost_ctrl.h" #include "video_core/gpu.h" diff --git a/src/core/hle/service/nvdrv/interface.cpp b/src/core/hle/service/nvdrv/interface.cpp index 187501be8e..2e1150867d 100644 --- a/src/core/hle/service/nvdrv/interface.cpp +++ b/src/core/hle/service/nvdrv/interface.cpp @@ -8,8 +8,8 @@ #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_thread.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/writable_event.h" #include "core/hle/service/nvdrv/interface.h" #include "core/hle/service/nvdrv/nvdata.h" #include "core/hle/service/nvdrv/nvdrv.h" diff --git a/src/core/hle/service/nvdrv/interface.h b/src/core/hle/service/nvdrv/interface.h index 5c777c59b1..0e764c53f8 100644 --- a/src/core/hle/service/nvdrv/interface.h +++ b/src/core/hle/service/nvdrv/interface.h @@ -9,7 +9,7 @@ #include "core/hle/service/service.h" namespace Kernel { -class WritableEvent; +class KWritableEvent; } namespace Service::Nvidia { diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp index caeab0bd21..b6c4c85e0e 100644 --- a/src/core/hle/service/nvdrv/nvdrv.cpp +++ b/src/core/hle/service/nvdrv/nvdrv.cpp @@ -8,7 +8,7 @@ #include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_readable_event.h" -#include "core/hle/kernel/writable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/service/nvdrv/devices/nvdevice.h" #include "core/hle/service/nvdrv/devices/nvdisp_disp0.h" #include "core/hle/service/nvdrv/devices/nvhost_as_gpu.h" @@ -42,7 +42,7 @@ Module::Module(Core::System& system) : syncpoint_manager{system.GPU()} { auto& kernel = system.Kernel(); for (u32 i = 0; i < MaxNvEvents; i++) { std::string event_label = fmt::format("NVDRV::NvEvent_{}", i); - events_interface.events[i] = {Kernel::WritableEvent::CreateEventPair(kernel, event_label)}; + events_interface.events[i] = {Kernel::KWritableEvent::CreateEventPair(kernel, event_label)}; events_interface.status[i] = EventState::Free; events_interface.registered[i] = false; } @@ -175,7 +175,7 @@ std::shared_ptr Module::GetEvent(const u32 event_id) con return events_interface.events[event_id].event.readable; } -std::shared_ptr Module::GetEventWriteable(const u32 event_id) const { +std::shared_ptr Module::GetEventWriteable(const u32 event_id) const { return events_interface.events[event_id].event.writable; } diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h index 8a75c92ff7..0d638e521a 100644 --- a/src/core/hle/service/nvdrv/nvdrv.h +++ b/src/core/hle/service/nvdrv/nvdrv.h @@ -8,7 +8,7 @@ #include #include #include "common/common_types.h" -#include "core/hle/kernel/writable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/service/nvdrv/nvdata.h" #include "core/hle/service/nvdrv/syncpoint_manager.h" #include "core/hle/service/service.h" @@ -134,7 +134,7 @@ public: std::shared_ptr GetEvent(u32 event_id) const; - std::shared_ptr GetEventWriteable(u32 event_id) const; + std::shared_ptr GetEventWriteable(u32 event_id) const; private: /// Manages syncpoints on the host diff --git a/src/core/hle/service/nvflinger/buffer_queue.cpp b/src/core/hle/service/nvflinger/buffer_queue.cpp index b7fd75d574..805f178aa3 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.cpp +++ b/src/core/hle/service/nvflinger/buffer_queue.cpp @@ -8,15 +8,15 @@ #include "common/logging/log.h" #include "core/core.h" #include "core/hle/kernel/k_readable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/writable_event.h" #include "core/hle/service/nvflinger/buffer_queue.h" namespace Service::NVFlinger { BufferQueue::BufferQueue(Kernel::KernelCore& kernel, u32 id, u64 layer_id) : id(id), layer_id(layer_id) { - buffer_wait_event = Kernel::WritableEvent::CreateEventPair(kernel, "BufferQueue NativeHandle"); + buffer_wait_event = Kernel::KWritableEvent::CreateEventPair(kernel, "BufferQueue NativeHandle"); } BufferQueue::~BufferQueue() = default; @@ -188,7 +188,7 @@ u32 BufferQueue::Query(QueryType type) { return 0; } -std::shared_ptr BufferQueue::GetWritableBufferWaitEvent() const { +std::shared_ptr BufferQueue::GetWritableBufferWaitEvent() const { return buffer_wait_event.writable; } diff --git a/src/core/hle/service/nvflinger/buffer_queue.h b/src/core/hle/service/nvflinger/buffer_queue.h index 8386e42b13..4de1441133 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.h +++ b/src/core/hle/service/nvflinger/buffer_queue.h @@ -13,8 +13,8 @@ #include "common/common_funcs.h" #include "common/math_util.h" #include "common/swap.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/object.h" -#include "core/hle/kernel/writable_event.h" #include "core/hle/service/nvdrv/nvdata.h" namespace Kernel { @@ -113,7 +113,7 @@ public: return is_connect; } - std::shared_ptr GetWritableBufferWaitEvent() const; + std::shared_ptr GetWritableBufferWaitEvent() const; std::shared_ptr GetBufferWaitEvent() const; diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h index 8ba9c64e34..6fe2c7f2a9 100644 --- a/src/core/hle/service/nvflinger/nvflinger.h +++ b/src/core/hle/service/nvflinger/nvflinger.h @@ -27,7 +27,7 @@ struct EventType; namespace Kernel { class KReadableEvent; -class WritableEvent; +class KWritableEvent; } // namespace Kernel namespace Service::Nvidia { diff --git a/src/core/hle/service/ptm/psm.cpp b/src/core/hle/service/ptm/psm.cpp index 1035951936..c1f7b33f19 100644 --- a/src/core/hle/service/ptm/psm.cpp +++ b/src/core/hle/service/ptm/psm.cpp @@ -8,8 +8,8 @@ #include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_readable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/writable_event.h" #include "core/hle/service/ptm/psm.h" #include "core/hle/service/service.h" #include "core/hle/service/sm/sm.h" @@ -31,7 +31,7 @@ public: RegisterHandlers(functions); - state_change_event = Kernel::WritableEvent::CreateEventPair( + state_change_event = Kernel::KWritableEvent::CreateEventPair( system_.Kernel(), "IPsmSession::state_change_event"); } diff --git a/src/core/hle/service/time/standard_user_system_clock_core.cpp b/src/core/hle/service/time/standard_user_system_clock_core.cpp index 8af17091cd..9362350a05 100644 --- a/src/core/hle/service/time/standard_user_system_clock_core.cpp +++ b/src/core/hle/service/time/standard_user_system_clock_core.cpp @@ -4,7 +4,7 @@ #include "common/assert.h" #include "core/core.h" -#include "core/hle/kernel/writable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/service/time/standard_local_system_clock_core.h" #include "core/hle/service/time/standard_network_system_clock_core.h" #include "core/hle/service/time/standard_user_system_clock_core.h" @@ -18,7 +18,7 @@ StandardUserSystemClockCore::StandardUserSystemClockCore( local_system_clock_core{local_system_clock_core}, network_system_clock_core{network_system_clock_core}, auto_correction_enabled{}, auto_correction_time{SteadyClockTimePoint::GetRandom()}, - auto_correction_event{Kernel::WritableEvent::CreateEventPair( + auto_correction_event{Kernel::KWritableEvent::CreateEventPair( system.Kernel(), "StandardUserSystemClockCore:AutoCorrectionEvent")} {} ResultCode StandardUserSystemClockCore::SetAutomaticCorrectionEnabled(Core::System& system, diff --git a/src/core/hle/service/time/standard_user_system_clock_core.h b/src/core/hle/service/time/standard_user_system_clock_core.h index ef3d468b70..30d3a2a0d3 100644 --- a/src/core/hle/service/time/standard_user_system_clock_core.h +++ b/src/core/hle/service/time/standard_user_system_clock_core.h @@ -4,7 +4,7 @@ #pragma once -#include "core/hle/kernel/writable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/service/time/clock_types.h" #include "core/hle/service/time/system_clock_core.h" diff --git a/src/core/hle/service/time/system_clock_context_update_callback.cpp b/src/core/hle/service/time/system_clock_context_update_callback.cpp index 5cdb807036..bca7d869e6 100644 --- a/src/core/hle/service/time/system_clock_context_update_callback.cpp +++ b/src/core/hle/service/time/system_clock_context_update_callback.cpp @@ -2,7 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "core/hle/kernel/writable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/service/time/errors.h" #include "core/hle/service/time/system_clock_context_update_callback.h" @@ -21,7 +21,7 @@ bool SystemClockContextUpdateCallback::NeedUpdate(const SystemClockContext& valu } void SystemClockContextUpdateCallback::RegisterOperationEvent( - std::shared_ptr&& writable_event) { + std::shared_ptr&& writable_event) { operation_event_list.emplace_back(std::move(writable_event)); } diff --git a/src/core/hle/service/time/system_clock_context_update_callback.h b/src/core/hle/service/time/system_clock_context_update_callback.h index 2b0fa7e75e..7979549582 100644 --- a/src/core/hle/service/time/system_clock_context_update_callback.h +++ b/src/core/hle/service/time/system_clock_context_update_callback.h @@ -9,7 +9,7 @@ #include "core/hle/service/time/clock_types.h" namespace Kernel { -class WritableEvent; +class KWritableEvent; } namespace Service::Time::Clock { @@ -24,7 +24,7 @@ public: bool NeedUpdate(const SystemClockContext& value) const; - void RegisterOperationEvent(std::shared_ptr&& writable_event); + void RegisterOperationEvent(std::shared_ptr&& writable_event); void BroadcastOperationEvent(); @@ -37,7 +37,7 @@ protected: private: bool has_context{}; - std::vector> operation_event_list; + std::vector> operation_event_list; }; } // namespace Service::Time::Clock diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp index a3fb26100b..02d5287a99 100644 --- a/src/core/hle/service/vi/display/vi_display.cpp +++ b/src/core/hle/service/vi/display/vi_display.cpp @@ -18,7 +18,7 @@ namespace Service::VI { Display::Display(u64 id, std::string name, Core::System& system) : id{id}, name{std::move(name)} { auto& kernel = system.Kernel(); vsync_event = - Kernel::WritableEvent::CreateEventPair(kernel, fmt::format("Display VSync Event {}", id)); + Kernel::KWritableEvent::CreateEventPair(kernel, fmt::format("Display VSync Event {}", id)); } Display::~Display() = default; diff --git a/src/core/hle/service/vi/display/vi_display.h b/src/core/hle/service/vi/display/vi_display.h index bf0d320d1a..b576c9cf20 100644 --- a/src/core/hle/service/vi/display/vi_display.h +++ b/src/core/hle/service/vi/display/vi_display.h @@ -9,7 +9,7 @@ #include #include "common/common_types.h" -#include "core/hle/kernel/writable_event.h" +#include "core/hle/kernel/k_writable_event.h" namespace Service::NVFlinger { class BufferQueue; diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index c573d474e3..8661895ae6 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -20,7 +20,7 @@ #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_thread.h" -#include "core/hle/kernel/writable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/service/nvdrv/nvdata.h" #include "core/hle/service/nvdrv/nvdrv.h" #include "core/hle/service/nvflinger/buffer_queue.h" From 4577dcd5f90ae4e4e19a5ebdcec0f6f847977edf Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 31 Jan 2021 00:51:16 -0800 Subject: [PATCH 03/10] common: common_funcs: Add R_UNLESS_NOLOG for scenarios that should not log. --- src/common/common_funcs.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index 71b64e32a3..cd3207a037 100644 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h @@ -104,6 +104,14 @@ __declspec(dllimport) void __stdcall DebugBreak(void); } \ } +/// Evaluates a boolean expression, and returns a result unless that expression is true. +#define R_UNLESS_NOLOG(expr, res) \ + { \ + if (!(expr)) { \ + return res; \ + } \ + } + #define R_SUCCEEDED(res) (res.IsSuccess()) /// Evaluates an expression that returns a result, and returns the result if it would fail. From e9446d232f74c6df695ad643bd6f89d5d3e029c0 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 31 Jan 2021 01:05:02 -0800 Subject: [PATCH 04/10] hle: kernel: KAddressArbiter: Use R_UNLESS_NOLOG where applicable. --- src/core/hle/kernel/k_address_arbiter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/hle/kernel/k_address_arbiter.cpp b/src/core/hle/kernel/k_address_arbiter.cpp index 1685d25bba..9309376ccd 100644 --- a/src/core/hle/kernel/k_address_arbiter.cpp +++ b/src/core/hle/kernel/k_address_arbiter.cpp @@ -211,7 +211,7 @@ ResultCode KAddressArbiter::SignalAndModifyByWaitingCountIfEqual(VAddr addr, s32 } R_UNLESS(succeeded, Svc::ResultInvalidCurrentMemory); - R_UNLESS(user_value == value, Svc::ResultInvalidState); + R_UNLESS_NOLOG(user_value == value, Svc::ResultInvalidState); while ((it != thread_tree.end()) && (count <= 0 || num_waiters < count) && (it->GetAddressArbiterKey() == addr)) { From 6bf80dfee0a9ed995fca48c0f5c9a786d14cdd6b Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 31 Jan 2021 01:37:41 -0800 Subject: [PATCH 05/10] hle: kernel: Implement KEvent. --- src/core/CMakeLists.txt | 2 ++ src/core/hle/kernel/k_event.cpp | 32 ++++++++++++++++++ src/core/hle/kernel/k_event.h | 57 +++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 src/core/hle/kernel/k_event.cpp create mode 100644 src/core/hle/kernel/k_event.h diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 73ee48f4f6..386d7bddf4 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -160,6 +160,8 @@ add_library(core STATIC hle/kernel/k_affinity_mask.h hle/kernel/k_condition_variable.cpp hle/kernel/k_condition_variable.h + hle/kernel/k_event.cpp + hle/kernel/k_event.h hle/kernel/k_light_condition_variable.h hle/kernel/k_light_lock.cpp hle/kernel/k_light_lock.h diff --git a/src/core/hle/kernel/k_event.cpp b/src/core/hle/kernel/k_event.cpp new file mode 100644 index 0000000000..bb2fa4ad56 --- /dev/null +++ b/src/core/hle/kernel/k_event.cpp @@ -0,0 +1,32 @@ +// Copyright 2021 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "core/hle/kernel/k_event.h" +#include "core/hle/kernel/k_readable_event.h" +#include "core/hle/kernel/k_writable_event.h" + +namespace Kernel { + +KEvent::KEvent(KernelCore& kernel, std::string&& name) : Object{kernel, std::move(name)} {} + +KEvent::~KEvent() = default; + +std::shared_ptr KEvent::Create(KernelCore& kernel, std::string&& name) { + return std::make_shared(kernel, std::move(name)); +} + +void KEvent::Initialize() { + // Create our sub events. + readable_event = std::make_shared(kernel, GetName() + ":Readable"); + writable_event = std::make_shared(kernel, GetName() + ":Writable"); + + // Initialize our sub sessions. + readable_event->Initialize(this); + writable_event->Initialize(this); + + // Mark initialized. + initialized = true; +} + +} // namespace Kernel diff --git a/src/core/hle/kernel/k_event.h b/src/core/hle/kernel/k_event.h new file mode 100644 index 0000000000..2fb887129a --- /dev/null +++ b/src/core/hle/kernel/k_event.h @@ -0,0 +1,57 @@ +// Copyright 2021 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include "core/hle/kernel/object.h" + +namespace Kernel { + +class KernelCore; +class KReadableEvent; +class KWritableEvent; + +class KEvent final : public Object { +public: + explicit KEvent(KernelCore& kernel, std::string&& name); + ~KEvent() override; + + static std::shared_ptr Create(KernelCore& kernel, std::string&& name); + + void Initialize(); + + void Finalize() override {} + + std::string GetTypeName() const override { + return "KEvent"; + } + + static constexpr HandleType HANDLE_TYPE = HandleType::Event; + HandleType GetHandleType() const override { + return HANDLE_TYPE; + } + + std::shared_ptr& GetReadableEvent() { + return readable_event; + } + + std::shared_ptr& GetWritableEvent() { + return writable_event; + } + + const std::shared_ptr& GetReadableEvent() const { + return readable_event; + } + + const std::shared_ptr& GetWritableEvent() const { + return writable_event; + } + +private: + std::shared_ptr readable_event; + std::shared_ptr writable_event; + bool initialized{}; +}; + +} // namespace Kernel From ff3c7c068b926399513bf7328c22e224ab0b53d6 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 31 Jan 2021 01:38:57 -0800 Subject: [PATCH 06/10] hle: kernel: Reimplement KReadableEvent and KWritableEvent. --- src/core/hle/kernel/k_readable_event.cpp | 44 ++++++------ src/core/hle/kernel/k_readable_event.h | 42 +++++------- .../hle/kernel/k_synchronization_object.cpp | 3 + .../hle/kernel/k_synchronization_object.h | 1 + src/core/hle/kernel/k_writable_event.cpp | 34 +++------- src/core/hle/kernel/k_writable_event.h | 42 ++++-------- src/core/hle/kernel/object.cpp | 6 +- src/core/hle/kernel/object.h | 7 +- src/core/hle/kernel/svc.cpp | 9 +-- src/core/hle/service/am/am.cpp | 67 ++++++++++--------- src/core/hle/service/am/am.h | 19 +++--- src/core/hle/service/am/applets/applets.cpp | 30 +++++---- src/core/hle/service/am/applets/applets.h | 12 ++-- src/core/hle/service/aoc/aoc_u.cpp | 18 ++--- src/core/hle/service/aoc/aoc_u.h | 4 +- src/core/hle/service/audio/audout_u.cpp | 11 +-- src/core/hle/service/audio/audren_u.cpp | 39 ++++++----- src/core/hle/service/bcat/backend/backend.cpp | 14 ++-- src/core/hle/service/bcat/backend/backend.h | 8 +-- src/core/hle/service/btdrv/btdrv.cpp | 9 +-- src/core/hle/service/btm/btm.cpp | 32 ++++----- src/core/hle/service/friend/friend.cpp | 10 +-- src/core/hle/service/hid/controllers/npad.cpp | 12 ++-- src/core/hle/service/hid/controllers/npad.h | 8 ++- src/core/hle/service/nfp/nfp.cpp | 25 ++++--- src/core/hle/service/nfp/nfp.h | 9 ++- src/core/hle/service/nifm/nifm.cpp | 13 ++-- src/core/hle/service/nim/nim.cpp | 14 ++-- .../hle/service/nvdrv/devices/nvhost_ctrl.cpp | 8 +-- src/core/hle/service/nvdrv/nvdrv.cpp | 10 +-- src/core/hle/service/nvdrv/nvdrv.h | 8 ++- .../hle/service/nvflinger/buffer_queue.cpp | 17 ++--- src/core/hle/service/nvflinger/buffer_queue.h | 8 ++- src/core/hle/service/ptm/psm.cpp | 16 +++-- .../time/standard_user_system_clock_core.cpp | 8 ++- .../time/standard_user_system_clock_core.h | 7 +- .../hle/service/vi/display/vi_display.cpp | 10 +-- src/core/hle/service/vi/display/vi_display.h | 7 +- 38 files changed, 342 insertions(+), 299 deletions(-) diff --git a/src/core/hle/kernel/k_readable_event.cpp b/src/core/hle/kernel/k_readable_event.cpp index e9e191bc62..0fa895c560 100644 --- a/src/core/hle/kernel/k_readable_event.cpp +++ b/src/core/hle/kernel/k_readable_event.cpp @@ -1,9 +1,10 @@ -// Copyright 2014 Citra Emulator Project +// Copyright 2021 yuzu emulator team // Licensed under GPLv2 or any later version // Refer to the license.txt file included. #include #include "common/assert.h" +#include "common/common_funcs.h" #include "common/logging/log.h" #include "core/hle/kernel/errors.h" #include "core/hle/kernel/k_readable_event.h" @@ -11,40 +12,43 @@ #include "core/hle/kernel/k_thread.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/object.h" +#include "core/hle/kernel/svc_results.h" namespace Kernel { -KReadableEvent::KReadableEvent(KernelCore& kernel) : KSynchronizationObject{kernel} {} +KReadableEvent::KReadableEvent(KernelCore& kernel, std::string&& name) + : KSynchronizationObject{kernel, std::move(name)} {} KReadableEvent::~KReadableEvent() = default; -void KReadableEvent::Signal() { - if (is_signaled) { - return; - } - - is_signaled = true; - NotifyAvailable(); -} - bool KReadableEvent::IsSignaled() const { ASSERT(kernel.GlobalSchedulerContext().IsLocked()); return is_signaled; } -void KReadableEvent::Clear() { - is_signaled = false; +ResultCode KReadableEvent::Signal() { + KScopedSchedulerLock lk{kernel}; + + if (!is_signaled) { + is_signaled = true; + NotifyAvailable(); + } + + return RESULT_SUCCESS; +} + +ResultCode KReadableEvent::Clear() { + Reset(); + + return RESULT_SUCCESS; } ResultCode KReadableEvent::Reset() { - KScopedSchedulerLock lock(kernel); - if (!is_signaled) { - LOG_TRACE(Kernel, "Handle is not signaled! object_id={}, object_type={}, object_name={}", - GetObjectId(), GetTypeName(), GetName()); - return ERR_INVALID_STATE; - } + KScopedSchedulerLock lk{kernel}; - Clear(); + R_UNLESS_NOLOG(is_signaled, Svc::ResultInvalidState); + + is_signaled = false; return RESULT_SUCCESS; } diff --git a/src/core/hle/kernel/k_readable_event.h b/src/core/hle/kernel/k_readable_event.h index 39eedc4118..e6f0fd9002 100644 --- a/src/core/hle/kernel/k_readable_event.h +++ b/src/core/hle/kernel/k_readable_event.h @@ -1,4 +1,4 @@ -// Copyright 2014 Citra Emulator Project +// Copyright 2021 yuzu emulator team // Licensed under GPLv2 or any later version // Refer to the license.txt file included. @@ -6,25 +6,20 @@ #include "core/hle/kernel/k_synchronization_object.h" #include "core/hle/kernel/object.h" - -union ResultCode; +#include "core/hle/result.h" namespace Kernel { class KernelCore; -class KWritableEvent; +class KEvent; class KReadableEvent final : public KSynchronizationObject { - friend class KWritableEvent; - public: + explicit KReadableEvent(KernelCore& kernel, std::string&& name); ~KReadableEvent() override; std::string GetTypeName() const override { - return "ReadableEvent"; - } - std::string GetName() const override { - return name; + return "KReadableEvent"; } static constexpr HandleType HANDLE_TYPE = HandleType::ReadableEvent; @@ -32,28 +27,25 @@ public: return HANDLE_TYPE; } - /// Unconditionally clears the readable event's state. - void Clear(); + KEvent* GetParent() const { + return parent; + } - /// Clears the readable event's state if and only if it - /// has already been signaled. - /// - /// @pre The event must be in a signaled state. If this event - /// is in an unsignaled state and this function is called, - /// then ERR_INVALID_STATE will be returned. - ResultCode Reset(); - - void Signal(); + void Initialize(KEvent* parent_) { + is_signaled = false; + parent = parent_; + } bool IsSignaled() const override; - void Finalize() override {} -private: - explicit KReadableEvent(KernelCore& kernel); + ResultCode Signal(); + ResultCode Clear(); + ResultCode Reset(); +private: bool is_signaled{}; - std::string name; ///< Name of event (optional) + KEvent* parent{}; }; } // namespace Kernel diff --git a/src/core/hle/kernel/k_synchronization_object.cpp b/src/core/hle/kernel/k_synchronization_object.cpp index a3b34f82fb..140cc46a72 100644 --- a/src/core/hle/kernel/k_synchronization_object.cpp +++ b/src/core/hle/kernel/k_synchronization_object.cpp @@ -132,6 +132,9 @@ ResultCode KSynchronizationObject::Wait(KernelCore& kernel, s32* out_index, KSynchronizationObject::KSynchronizationObject(KernelCore& kernel) : Object{kernel} {} +KSynchronizationObject::KSynchronizationObject(KernelCore& kernel, std::string&& name) + : Object{kernel, std::move(name)} {} + KSynchronizationObject::~KSynchronizationObject() = default; void KSynchronizationObject::NotifyAvailable(ResultCode result) { diff --git a/src/core/hle/kernel/k_synchronization_object.h b/src/core/hle/kernel/k_synchronization_object.h index f65c71c284..5803718fdd 100644 --- a/src/core/hle/kernel/k_synchronization_object.h +++ b/src/core/hle/kernel/k_synchronization_object.h @@ -33,6 +33,7 @@ public: protected: explicit KSynchronizationObject(KernelCore& kernel); + explicit KSynchronizationObject(KernelCore& kernel, std::string&& name); virtual ~KSynchronizationObject(); void NotifyAvailable(ResultCode result); diff --git a/src/core/hle/kernel/k_writable_event.cpp b/src/core/hle/kernel/k_writable_event.cpp index d2857b4c3a..25c52edb26 100644 --- a/src/core/hle/kernel/k_writable_event.cpp +++ b/src/core/hle/kernel/k_writable_event.cpp @@ -1,41 +1,27 @@ -// Copyright 2014 Citra Emulator Project +// Copyright 2021 yuzu emulator team // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include -#include "common/assert.h" +#include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_readable_event.h" -#include "core/hle/kernel/k_thread.h" #include "core/hle/kernel/k_writable_event.h" -#include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/object.h" namespace Kernel { -KWritableEvent::KWritableEvent(KernelCore& kernel) : Object{kernel} {} +KWritableEvent::KWritableEvent(KernelCore& kernel, std::string&& name) + : Object{kernel, std::move(name)} {} KWritableEvent::~KWritableEvent() = default; -EventPair KWritableEvent::CreateEventPair(KernelCore& kernel, std::string name) { - std::shared_ptr writable_event(new KWritableEvent(kernel)); - std::shared_ptr readable_event(new KReadableEvent(kernel)); - - writable_event->name = name + ":Writable"; - writable_event->readable = readable_event; - readable_event->name = name + ":Readable"; - - return {std::move(readable_event), std::move(writable_event)}; +void KWritableEvent::Initialize(KEvent* parent_) { + parent = parent_; } -std::shared_ptr KWritableEvent::GetReadableEvent() const { - return readable; +ResultCode KWritableEvent::Signal() { + return parent->GetReadableEvent()->Signal(); } -void KWritableEvent::Signal() { - readable->Signal(); -} - -void KWritableEvent::Clear() { - readable->Clear(); +ResultCode KWritableEvent::Clear() { + return parent->GetReadableEvent()->Clear(); } } // namespace Kernel diff --git a/src/core/hle/kernel/k_writable_event.h b/src/core/hle/kernel/k_writable_event.h index ad5514b525..518f5448db 100644 --- a/src/core/hle/kernel/k_writable_event.h +++ b/src/core/hle/kernel/k_writable_event.h @@ -4,37 +4,21 @@ #pragma once -#include - #include "core/hle/kernel/object.h" +#include "core/hle/result.h" namespace Kernel { class KernelCore; -class KReadableEvent; -class KWritableEvent; - -struct EventPair { - std::shared_ptr readable; - std::shared_ptr writable; -}; +class KEvent; class KWritableEvent final : public Object { public: + explicit KWritableEvent(KernelCore& kernel, std::string&& name); ~KWritableEvent() override; - /** - * Creates an event - * @param kernel The kernel instance to create this event under. - * @param name Optional name of event - */ - static EventPair CreateEventPair(KernelCore& kernel, std::string name = "Unknown"); - std::string GetTypeName() const override { - return "WritableEvent"; - } - std::string GetName() const override { - return name; + return "KWritableEvent"; } static constexpr HandleType HANDLE_TYPE = HandleType::WritableEvent; @@ -42,19 +26,19 @@ public: return HANDLE_TYPE; } - std::shared_ptr GetReadableEvent() const; - - void Signal(); - void Clear(); + void Initialize(KEvent* parent_); void Finalize() override {} + ResultCode Signal(); + ResultCode Clear(); + + KEvent* GetParent() const { + return parent; + } + private: - explicit KWritableEvent(KernelCore& kernel); - - std::shared_ptr readable; - - std::string name; ///< Name of event (optional) + KEvent* parent{}; }; } // namespace Kernel diff --git a/src/core/hle/kernel/object.cpp b/src/core/hle/kernel/object.cpp index 2c571792b2..d7f40c4038 100644 --- a/src/core/hle/kernel/object.cpp +++ b/src/core/hle/kernel/object.cpp @@ -8,7 +8,10 @@ namespace Kernel { -Object::Object(KernelCore& kernel) : kernel{kernel}, object_id{kernel.CreateNewObjectID()} {} +Object::Object(KernelCore& kernel_) + : kernel{kernel_}, object_id{kernel_.CreateNewObjectID()}, name{"[UNKNOWN KERNEL OBJECT]"} {} +Object::Object(KernelCore& kernel_, std::string&& name_) + : kernel{kernel_}, object_id{kernel_.CreateNewObjectID()}, name{std::move(name_)} {} Object::~Object() = default; bool Object::IsWaitable() const { @@ -21,6 +24,7 @@ bool Object::IsWaitable() const { return true; case HandleType::Unknown: + case HandleType::Event: case HandleType::WritableEvent: case HandleType::SharedMemory: case HandleType::TransferMemory: diff --git a/src/core/hle/kernel/object.h b/src/core/hle/kernel/object.h index be7fcb5fb3..501e58b33d 100644 --- a/src/core/hle/kernel/object.h +++ b/src/core/hle/kernel/object.h @@ -18,6 +18,7 @@ using Handle = u32; enum class HandleType : u32 { Unknown, + Event, WritableEvent, ReadableEvent, SharedMemory, @@ -34,7 +35,8 @@ enum class HandleType : u32 { class Object : NonCopyable, public std::enable_shared_from_this { public: - explicit Object(KernelCore& kernel); + explicit Object(KernelCore& kernel_); + explicit Object(KernelCore& kernel_, std::string&& name_); virtual ~Object(); /// Returns a unique identifier for the object. For debugging purposes only. @@ -46,7 +48,7 @@ public: return "[BAD KERNEL OBJECT TYPE]"; } virtual std::string GetName() const { - return "[UNKNOWN KERNEL OBJECT]"; + return name; } virtual HandleType GetHandleType() const = 0; @@ -69,6 +71,7 @@ protected: private: std::atomic object_id{0}; + std::string name; }; template diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index f94eecbb8e..9d036f45dd 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -26,6 +26,7 @@ #include "core/hle/kernel/handle_table.h" #include "core/hle/kernel/k_address_arbiter.h" #include "core/hle/kernel/k_condition_variable.h" +#include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_resource_limit.h" #include "core/hle/kernel/k_scheduler.h" @@ -1870,18 +1871,18 @@ static ResultCode CreateEvent(Core::System& system, Handle* write_handle, Handle LOG_DEBUG(Kernel_SVC, "called"); auto& kernel = system.Kernel(); - const auto [readable_event, writable_event] = - KWritableEvent::CreateEventPair(kernel, "CreateEvent"); + const auto event = KEvent::Create(kernel, "CreateEvent"); + event->Initialize(); HandleTable& handle_table = kernel.CurrentProcess()->GetHandleTable(); - const auto write_create_result = handle_table.Create(writable_event); + const auto write_create_result = handle_table.Create(event->GetWritableEvent()); if (write_create_result.Failed()) { return write_create_result.Code(); } *write_handle = *write_create_result; - const auto read_create_result = handle_table.Create(readable_event); + const auto read_create_result = handle_table.Create(event->GetReadableEvent()); if (read_create_result.Failed()) { handle_table.Close(*write_create_result); return read_create_result.Code(); diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index e1aa208baa..bb77c2569f 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -13,6 +13,7 @@ #include "core/file_sys/registered_cache.h" #include "core/file_sys/savedata_factory.h" #include "core/hle/ipc_helpers.h" +#include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" @@ -303,17 +304,18 @@ ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nv RegisterHandlers(functions); auto& kernel = system.Kernel(); - launchable_event = - Kernel::KWritableEvent::CreateEventPair(kernel, "ISelfController:LaunchableEvent"); + launchable_event = Kernel::KEvent::Create(kernel, "ISelfController:LaunchableEvent"); + launchable_event->Initialize(); // This event is created by AM on the first time GetAccumulatedSuspendedTickChangedEvent() is // called. Yuzu can just create it unconditionally, since it doesn't need to support multiple // ISelfControllers. The event is signaled on creation, and on transition from suspended -> not // suspended if the event has previously been created by a call to // GetAccumulatedSuspendedTickChangedEvent. - accumulated_suspended_tick_changed_event = Kernel::KWritableEvent::CreateEventPair( - kernel, "ISelfController:AccumulatedSuspendedTickChangedEvent"); - accumulated_suspended_tick_changed_event.writable->Signal(); + accumulated_suspended_tick_changed_event = + Kernel::KEvent::Create(kernel, "ISelfController:AccumulatedSuspendedTickChangedEvent"); + accumulated_suspended_tick_changed_event->Initialize(); + accumulated_suspended_tick_changed_event->GetWritableEvent()->Signal(); } ISelfController::~ISelfController() = default; @@ -372,11 +374,11 @@ void ISelfController::LeaveFatalSection(Kernel::HLERequestContext& ctx) { void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); - launchable_event.writable->Signal(); + launchable_event->GetWritableEvent()->Signal(); IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(launchable_event.readable); + rb.PushCopyObjects(launchable_event->GetReadableEvent()); } void ISelfController::SetScreenShotPermission(Kernel::HLERequestContext& ctx) { @@ -555,41 +557,42 @@ void ISelfController::GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequest IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(accumulated_suspended_tick_changed_event.readable); + rb.PushCopyObjects(accumulated_suspended_tick_changed_event->GetReadableEvent()); } AppletMessageQueue::AppletMessageQueue(Kernel::KernelCore& kernel) { - on_new_message = - Kernel::KWritableEvent::CreateEventPair(kernel, "AMMessageQueue:OnMessageReceived"); + on_new_message = Kernel::KEvent::Create(kernel, "AMMessageQueue:OnMessageReceived"); + on_new_message->Initialize(); on_operation_mode_changed = - Kernel::KWritableEvent::CreateEventPair(kernel, "AMMessageQueue:OperationModeChanged"); + Kernel::KEvent::Create(kernel, "AMMessageQueue:OperationModeChanged"); + on_operation_mode_changed->Initialize(); } AppletMessageQueue::~AppletMessageQueue() = default; const std::shared_ptr& AppletMessageQueue::GetMessageReceiveEvent() const { - return on_new_message.readable; + return on_new_message->GetReadableEvent(); } const std::shared_ptr& AppletMessageQueue::GetOperationModeChangedEvent() const { - return on_operation_mode_changed.readable; + return on_operation_mode_changed->GetReadableEvent(); } void AppletMessageQueue::PushMessage(AppletMessage msg) { messages.push(msg); - on_new_message.writable->Signal(); + on_new_message->GetWritableEvent()->Signal(); } AppletMessageQueue::AppletMessage AppletMessageQueue::PopMessage() { if (messages.empty()) { - on_new_message.writable->Clear(); + on_new_message->GetWritableEvent()->Clear(); return AppletMessage::NoMessage; } auto msg = messages.front(); messages.pop(); if (messages.empty()) { - on_new_message.writable->Clear(); + on_new_message->GetWritableEvent()->Clear(); } return msg; } @@ -601,7 +604,7 @@ std::size_t AppletMessageQueue::GetMessageCount() const { void AppletMessageQueue::OperationModeChanged() { PushMessage(AppletMessage::OperationModeChanged); PushMessage(AppletMessage::PerformanceModeChanged); - on_operation_mode_changed.writable->Signal(); + on_operation_mode_changed->GetWritableEvent()->Signal(); } void AppletMessageQueue::RequestExit() { @@ -1229,14 +1232,15 @@ IApplicationFunctions::IApplicationFunctions(Core::System& system_) RegisterHandlers(functions); auto& kernel = system.Kernel(); - gpu_error_detected_event = Kernel::KWritableEvent::CreateEventPair( - kernel, "IApplicationFunctions:GpuErrorDetectedSystemEvent"); - - friend_invitation_storage_channel_event = Kernel::KWritableEvent::CreateEventPair( - kernel, "IApplicationFunctions:FriendInvitationStorageChannelEvent"); - - health_warning_disappeared_system_event = Kernel::WritableEvent::CreateEventPair( - kernel, "IApplicationFunctions:HealthWarningDisappearedSystemEvent"); + gpu_error_detected_event = + Kernel::KEvent::Create(kernel, "IApplicationFunctions:GpuErrorDetectedSystemEvent"); + gpu_error_detected_event->Initialize(); + friend_invitation_storage_channel_event = + Kernel::KEvent::Create(kernel, "IApplicationFunctions:FriendInvitationStorageChannelEvent"); + friend_invitation_storage_channel_event->Initialize(); + health_warning_disappeared_system_event = + Kernel::KEvent::Create(kernel, "IApplicationFunctions:HealthWarningDisappearedSystemEvent"); + health_warning_disappeared_system_event->Initialize(); } IApplicationFunctions::~IApplicationFunctions() = default; @@ -1633,7 +1637,7 @@ void IApplicationFunctions::GetGpuErrorDetectedSystemEvent(Kernel::HLERequestCon IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(gpu_error_detected_event.readable); + rb.PushCopyObjects(gpu_error_detected_event->GetReadableEvent()); } void IApplicationFunctions::GetFriendInvitationStorageChannelEvent(Kernel::HLERequestContext& ctx) { @@ -1641,7 +1645,7 @@ void IApplicationFunctions::GetFriendInvitationStorageChannelEvent(Kernel::HLERe IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(friend_invitation_storage_channel_event.readable); + rb.PushCopyObjects(friend_invitation_storage_channel_event->GetReadableEvent()); } void IApplicationFunctions::TryPopFromFriendInvitationStorageChannel( @@ -1657,7 +1661,7 @@ void IApplicationFunctions::GetHealthWarningDisappearedSystemEvent(Kernel::HLERe IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(health_warning_disappeared_system_event.readable); + rb.PushCopyObjects(health_warning_disappeared_system_event->GetReadableEvent()); } void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger, @@ -1693,8 +1697,9 @@ IHomeMenuFunctions::IHomeMenuFunctions(Core::System& system_) RegisterHandlers(functions); - pop_from_general_channel_event = Kernel::KWritableEvent::CreateEventPair( - system.Kernel(), "IHomeMenuFunctions:PopFromGeneralChannelEvent"); + pop_from_general_channel_event = + Kernel::KEvent::Create(system.Kernel(), "IHomeMenuFunctions:PopFromGeneralChannelEvent"); + pop_from_general_channel_event->Initialize(); } IHomeMenuFunctions::~IHomeMenuFunctions() = default; @@ -1711,7 +1716,7 @@ void IHomeMenuFunctions::GetPopFromGeneralChannelEvent(Kernel::HLERequestContext IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(pop_from_general_channel_event.readable); + rb.PushCopyObjects(pop_from_general_channel_event->GetReadableEvent()); } IGlobalStateController::IGlobalStateController(Core::System& system_) diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index 37d7b41de4..6911f0d6e8 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -7,11 +7,12 @@ #include #include #include -#include "core/hle/kernel/k_writable_event.h" + #include "core/hle/service/service.h" namespace Kernel { class KernelCore; +class KEvent; class TransferMemory; } // namespace Kernel @@ -65,8 +66,8 @@ public: private: std::queue messages; - Kernel::EventPair on_new_message; - Kernel::EventPair on_operation_mode_changed; + std::shared_ptr on_new_message; + std::shared_ptr on_operation_mode_changed; }; class IWindowController final : public ServiceFramework { @@ -153,8 +154,8 @@ private: }; NVFlinger::NVFlinger& nvflinger; - Kernel::EventPair launchable_event; - Kernel::EventPair accumulated_suspended_tick_changed_event; + std::shared_ptr launchable_event; + std::shared_ptr accumulated_suspended_tick_changed_event; u32 idle_time_detection_extension = 0; u64 num_fatal_sections_entered = 0; @@ -295,9 +296,9 @@ private: bool launch_popped_application_specific = false; bool launch_popped_account_preselect = false; s32 previous_program_index{-1}; - Kernel::EventPair gpu_error_detected_event; - Kernel::EventPair friend_invitation_storage_channel_event; - Kernel::EventPair health_warning_disappeared_system_event; + std::shared_ptr gpu_error_detected_event; + std::shared_ptr friend_invitation_storage_channel_event; + std::shared_ptr health_warning_disappeared_system_event; }; class IHomeMenuFunctions final : public ServiceFramework { @@ -309,7 +310,7 @@ private: void RequestToGetForeground(Kernel::HLERequestContext& ctx); void GetPopFromGeneralChannelEvent(Kernel::HLERequestContext& ctx); - Kernel::EventPair pop_from_general_channel_event; + std::shared_ptr pop_from_general_channel_event; }; class IGlobalStateController final : public ServiceFramework { diff --git a/src/core/hle/service/am/applets/applets.cpp b/src/core/hle/service/am/applets/applets.cpp index c96b455d32..e2f3b75631 100644 --- a/src/core/hle/service/am/applets/applets.cpp +++ b/src/core/hle/service/am/applets/applets.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include + #include "common/assert.h" #include "core/core.h" #include "core/frontend/applets/controller.h" @@ -11,6 +12,7 @@ #include "core/frontend/applets/profile_select.h" #include "core/frontend/applets/software_keyboard.h" #include "core/frontend/applets/web_browser.h" +#include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/server_session.h" @@ -27,11 +29,13 @@ namespace Service::AM::Applets { AppletDataBroker::AppletDataBroker(Kernel::KernelCore& kernel) { state_changed_event = - Kernel::KWritableEvent::CreateEventPair(kernel, "ILibraryAppletAccessor:StateChangedEvent"); - pop_out_data_event = - Kernel::KWritableEvent::CreateEventPair(kernel, "ILibraryAppletAccessor:PopDataOutEvent"); - pop_interactive_out_data_event = Kernel::KWritableEvent::CreateEventPair( - kernel, "ILibraryAppletAccessor:PopInteractiveDataOutEvent"); + Kernel::KEvent::Create(kernel, "ILibraryAppletAccessor:StateChangedEvent"); + state_changed_event->Initialize(); + pop_out_data_event = Kernel::KEvent::Create(kernel, "ILibraryAppletAccessor:PopDataOutEvent"); + pop_out_data_event->Initialize(); + pop_interactive_out_data_event = + Kernel::KEvent::Create(kernel, "ILibraryAppletAccessor:PopInteractiveDataOutEvent"); + pop_interactive_out_data_event->Initialize(); } AppletDataBroker::~AppletDataBroker() = default; @@ -58,7 +62,7 @@ std::shared_ptr AppletDataBroker::PopNormalDataToGame() { auto out = std::move(out_channel.front()); out_channel.pop_front(); - pop_out_data_event.writable->Clear(); + pop_out_data_event->GetWritableEvent()->Clear(); return out; } @@ -77,7 +81,7 @@ std::shared_ptr AppletDataBroker::PopInteractiveDataToGame() { auto out = std::move(out_interactive_channel.front()); out_interactive_channel.pop_front(); - pop_interactive_out_data_event.writable->Clear(); + pop_interactive_out_data_event->GetWritableEvent()->Clear(); return out; } @@ -96,7 +100,7 @@ void AppletDataBroker::PushNormalDataFromGame(std::shared_ptr&& storag void AppletDataBroker::PushNormalDataFromApplet(std::shared_ptr&& storage) { out_channel.emplace_back(std::move(storage)); - pop_out_data_event.writable->Signal(); + pop_out_data_event->GetWritableEvent()->Signal(); } void AppletDataBroker::PushInteractiveDataFromGame(std::shared_ptr&& storage) { @@ -105,23 +109,23 @@ void AppletDataBroker::PushInteractiveDataFromGame(std::shared_ptr&& s void AppletDataBroker::PushInteractiveDataFromApplet(std::shared_ptr&& storage) { out_interactive_channel.emplace_back(std::move(storage)); - pop_interactive_out_data_event.writable->Signal(); + pop_interactive_out_data_event->GetWritableEvent()->Signal(); } void AppletDataBroker::SignalStateChanged() const { - state_changed_event.writable->Signal(); + state_changed_event->GetWritableEvent()->Signal(); } std::shared_ptr AppletDataBroker::GetNormalDataEvent() const { - return pop_out_data_event.readable; + return pop_out_data_event->GetReadableEvent(); } std::shared_ptr AppletDataBroker::GetInteractiveDataEvent() const { - return pop_interactive_out_data_event.readable; + return pop_interactive_out_data_event->GetReadableEvent(); } std::shared_ptr AppletDataBroker::GetStateChangedEvent() const { - return state_changed_event.readable; + return state_changed_event->GetReadableEvent(); } Applet::Applet(Kernel::KernelCore& kernel_) : broker{kernel_} {} diff --git a/src/core/hle/service/am/applets/applets.h b/src/core/hle/service/am/applets/applets.h index 7ebfb9bbd7..b9a006317a 100644 --- a/src/core/hle/service/am/applets/applets.h +++ b/src/core/hle/service/am/applets/applets.h @@ -6,8 +6,8 @@ #include #include + #include "common/swap.h" -#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/object.h" union ResultCode; @@ -29,7 +29,9 @@ class WebBrowserApplet; namespace Kernel { class KernelCore; -} +class KEvent; +class KReadableEvent; +} // namespace Kernel namespace Service::AM { @@ -106,13 +108,13 @@ private: // PopInteractiveDataToGame and PushInteractiveDataFromApplet std::deque> out_interactive_channel; - Kernel::EventPair state_changed_event; + std::shared_ptr state_changed_event; // Signaled on PushNormalDataFromApplet - Kernel::EventPair pop_out_data_event; + std::shared_ptr pop_out_data_event; // Signaled on PushInteractiveDataFromApplet - Kernel::EventPair pop_interactive_out_data_event; + std::shared_ptr pop_interactive_out_data_event; }; class Applet { diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp index 334920c234..8d657c0bfe 100644 --- a/src/core/hle/service/aoc/aoc_u.cpp +++ b/src/core/hle/service/aoc/aoc_u.cpp @@ -5,6 +5,7 @@ #include #include #include + #include "common/logging/log.h" #include "core/core.h" #include "core/file_sys/common_funcs.h" @@ -14,8 +15,8 @@ #include "core/file_sys/patch_manager.h" #include "core/file_sys/registered_cache.h" #include "core/hle/ipc_helpers.h" +#include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_readable_event.h" -#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/process.h" #include "core/hle/service/aoc/aoc_u.h" @@ -62,8 +63,9 @@ public: RegisterHandlers(functions); - purchased_event = Kernel::KWritableEvent::CreateEventPair( - system.Kernel(), "IPurchaseEventManager:PurchasedEvent"); + purchased_event = + Kernel::KEvent::Create(system.Kernel(), "IPurchaseEventManager:PurchasedEvent"); + purchased_event->Initialize(); } private: @@ -96,10 +98,10 @@ private: IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(purchased_event.readable); + rb.PushCopyObjects(purchased_event->GetReadableEvent()); } - Kernel::EventPair purchased_event; + std::shared_ptr purchased_event; }; AOC_U::AOC_U(Core::System& system_) @@ -124,8 +126,8 @@ AOC_U::AOC_U(Core::System& system_) RegisterHandlers(functions); auto& kernel = system.Kernel(); - aoc_change_event = - Kernel::KWritableEvent::CreateEventPair(kernel, "GetAddOnContentListChanged:Event"); + aoc_change_event = Kernel::KEvent::Create(kernel, "GetAddOnContentListChanged:Event"); + aoc_change_event->Initialize(); } AOC_U::~AOC_U() = default; @@ -252,7 +254,7 @@ void AOC_U::GetAddOnContentListChangedEvent(Kernel::HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(aoc_change_event.readable); + rb.PushCopyObjects(aoc_change_event->GetReadableEvent()); } void AOC_U::CreateEcPurchasedEventManager(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/aoc/aoc_u.h b/src/core/hle/service/aoc/aoc_u.h index 594152de58..1aa23529e5 100644 --- a/src/core/hle/service/aoc/aoc_u.h +++ b/src/core/hle/service/aoc/aoc_u.h @@ -11,7 +11,7 @@ class System; } namespace Kernel { -class KWritableEvent; +class KEvent; } namespace Service::AOC { @@ -31,7 +31,7 @@ private: void CreatePermanentEcPurchasedEventManager(Kernel::HLERequestContext& ctx); std::vector add_on_content; - Kernel::EventPair aoc_change_event; + std::shared_ptr aoc_change_event; }; /// Registers all AOC services with the specified service manager. diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp index 3c60ec43d5..5ed9cb20e4 100644 --- a/src/core/hle/service/audio/audout_u.cpp +++ b/src/core/hle/service/audio/audout_u.cpp @@ -14,6 +14,7 @@ #include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/hle_ipc.h" +#include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" @@ -66,13 +67,13 @@ public: RegisterHandlers(functions); // This is the event handle used to check if the audio buffer was released - buffer_event = - Kernel::KWritableEvent::CreateEventPair(system.Kernel(), "IAudioOutBufferReleased"); + buffer_event = Kernel::KEvent::Create(system.Kernel(), "IAudioOutBufferReleased"); + buffer_event->Initialize(); stream = audio_core.OpenStream(system.CoreTiming(), audio_params.sample_rate, audio_params.channel_count, std::move(unique_name), [this] { const auto guard = LockService(); - buffer_event.writable->Signal(); + buffer_event->GetWritableEvent()->Signal(); }); } @@ -125,7 +126,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(buffer_event.readable); + rb.PushCopyObjects(buffer_event->GetReadableEvent()); } void AppendAudioOutBufferImpl(Kernel::HLERequestContext& ctx) { @@ -219,7 +220,7 @@ private: [[maybe_unused]] AudoutParams audio_params{}; /// This is the event handle used to check if the audio buffer was released - Kernel::EventPair buffer_event; + std::shared_ptr buffer_event; Core::Memory::Memory& main_memory; }; diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index aa50e73a9d..b2b2ffc5aa 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp @@ -16,6 +16,7 @@ #include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/hle_ipc.h" +#include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" @@ -47,13 +48,13 @@ public: // clang-format on RegisterHandlers(functions); - system_event = - Kernel::KWritableEvent::CreateEventPair(system.Kernel(), "IAudioRenderer:SystemEvent"); + system_event = Kernel::KEvent::Create(system.Kernel(), "IAudioRenderer:SystemEvent"); + system_event->Initialize(); renderer = std::make_unique( system.CoreTiming(), system.Memory(), audren_params, [this]() { const auto guard = LockService(); - system_event.writable->Signal(); + system_event->GetWritableEvent()->Signal(); }, instance_number); } @@ -126,7 +127,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(system_event.readable); + rb.PushCopyObjects(system_event->GetReadableEvent()); } void SetRenderingTimeLimit(Kernel::HLERequestContext& ctx) { @@ -160,7 +161,7 @@ private: rb.Push(ERR_NOT_SUPPORTED); } - Kernel::EventPair system_event; + std::shared_ptr system_event; std::unique_ptr renderer; u32 rendering_time_limit_percent = 100; }; @@ -187,17 +188,19 @@ public: RegisterHandlers(functions); auto& kernel = system.Kernel(); - buffer_event = - Kernel::KWritableEvent::CreateEventPair(kernel, "IAudioOutBufferReleasedEvent"); + buffer_event = Kernel::KEvent::Create(kernel, "IAudioOutBufferReleasedEvent"); + buffer_event->Initialize(); // Should be similar to audio_output_device_switch_event - audio_input_device_switch_event = Kernel::KWritableEvent::CreateEventPair( - kernel, "IAudioDevice:AudioInputDeviceSwitchedEvent"); + audio_input_device_switch_event = + Kernel::KEvent::Create(kernel, "IAudioDevice:AudioInputDeviceSwitchedEvent"); + audio_input_device_switch_event->Initialize(); // Should only be signalled when an audio output device has been changed, example: speaker // to headset - audio_output_device_switch_event = Kernel::KWritableEvent::CreateEventPair( - kernel, "IAudioDevice:AudioOutputDeviceSwitchedEvent"); + audio_output_device_switch_event = + Kernel::KEvent::Create(kernel, "IAudioDevice:AudioOutputDeviceSwitchedEvent"); + audio_output_device_switch_event->Initialize(); } private: @@ -286,11 +289,11 @@ private: void QueryAudioDeviceSystemEvent(Kernel::HLERequestContext& ctx) { LOG_WARNING(Service_Audio, "(STUBBED) called"); - buffer_event.writable->Signal(); + buffer_event->GetWritableEvent()->Signal(); IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(buffer_event.readable); + rb.PushCopyObjects(buffer_event->GetReadableEvent()); } void GetActiveChannelCount(Kernel::HLERequestContext& ctx) { @@ -307,7 +310,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(audio_input_device_switch_event.readable); + rb.PushCopyObjects(audio_input_device_switch_event->GetReadableEvent()); } void QueryAudioDeviceOutputEvent(Kernel::HLERequestContext& ctx) { @@ -315,13 +318,13 @@ private: IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(audio_output_device_switch_event.readable); + rb.PushCopyObjects(audio_output_device_switch_event->GetReadableEvent()); } u32_le revision = 0; - Kernel::EventPair buffer_event; - Kernel::EventPair audio_input_device_switch_event; - Kernel::EventPair audio_output_device_switch_event; + std::shared_ptr buffer_event; + std::shared_ptr audio_input_device_switch_event; + std::shared_ptr audio_output_device_switch_event; }; // namespace Audio diff --git a/src/core/hle/service/bcat/backend/backend.cpp b/src/core/hle/service/bcat/backend/backend.cpp index 3b853e9e44..92d25dbe43 100644 --- a/src/core/hle/service/bcat/backend/backend.cpp +++ b/src/core/hle/service/bcat/backend/backend.cpp @@ -5,6 +5,9 @@ #include "common/hex_util.h" #include "common/logging/log.h" #include "core/core.h" +#include "core/hle/kernel/k_event.h" +#include "core/hle/kernel/k_readable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/lock.h" #include "core/hle/service/bcat/backend/backend.h" @@ -12,12 +15,13 @@ namespace Service::BCAT { ProgressServiceBackend::ProgressServiceBackend(Kernel::KernelCore& kernel, std::string_view event_name) { - event = Kernel::KWritableEvent::CreateEventPair( - kernel, std::string("ProgressServiceBackend:UpdateEvent:").append(event_name)); + event = Kernel::KEvent::Create(kernel, + "ProgressServiceBackend:UpdateEvent:" + std::string(event_name)); + event->Initialize(); } std::shared_ptr ProgressServiceBackend::GetEvent() const { - return event.readable; + return event->GetReadableEvent(); } DeliveryCacheProgressImpl& ProgressServiceBackend::GetImpl() { @@ -85,9 +89,9 @@ void ProgressServiceBackend::FinishDownload(ResultCode result) { void ProgressServiceBackend::SignalUpdate() const { if (need_hle_lock) { std::lock_guard lock(HLE::g_hle_lock); - event.writable->Signal(); + event->GetWritableEvent()->Signal(); } else { - event.writable->Signal(); + event->GetWritableEvent()->Signal(); } } diff --git a/src/core/hle/service/bcat/backend/backend.h b/src/core/hle/service/bcat/backend/backend.h index b190943ace..db585b0690 100644 --- a/src/core/hle/service/bcat/backend/backend.h +++ b/src/core/hle/service/bcat/backend/backend.h @@ -11,8 +11,6 @@ #include "common/common_types.h" #include "core/file_sys/vfs_types.h" -#include "core/hle/kernel/k_readable_event.h" -#include "core/hle/kernel/k_writable_event.h" #include "core/hle/result.h" namespace Core { @@ -21,7 +19,9 @@ class System; namespace Kernel { class KernelCore; -} +class KEvent; +class KReadableEvent; +} // namespace Kernel namespace Service::BCAT { @@ -104,7 +104,7 @@ private: void SignalUpdate() const; DeliveryCacheProgressImpl impl{}; - Kernel::EventPair event; + std::shared_ptr event; bool need_hle_lock = false; }; diff --git a/src/core/hle/service/btdrv/btdrv.cpp b/src/core/hle/service/btdrv/btdrv.cpp index 4c78cd0083..17a2ac8996 100644 --- a/src/core/hle/service/btdrv/btdrv.cpp +++ b/src/core/hle/service/btdrv/btdrv.cpp @@ -6,8 +6,8 @@ #include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/hle_ipc.h" +#include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_readable_event.h" -#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" #include "core/hle/service/btdrv/btdrv.h" #include "core/hle/service/service.h" @@ -35,7 +35,8 @@ public: RegisterHandlers(functions); auto& kernel = system.Kernel(); - register_event = Kernel::KWritableEvent::CreateEventPair(kernel, "BT:RegisterEvent"); + register_event = Kernel::KEvent::Create(kernel, "BT:RegisterEvent"); + register_event->Initialize(); } private: @@ -44,10 +45,10 @@ private: IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(register_event.readable); + rb.PushCopyObjects(register_event->GetReadableEvent()); } - Kernel::EventPair register_event; + std::shared_ptr register_event; }; class BtDrv final : public ServiceFramework { diff --git a/src/core/hle/service/btm/btm.cpp b/src/core/hle/service/btm/btm.cpp index 3af51d6030..9cf2ee92a8 100644 --- a/src/core/hle/service/btm/btm.cpp +++ b/src/core/hle/service/btm/btm.cpp @@ -8,8 +8,8 @@ #include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/hle_ipc.h" +#include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_readable_event.h" -#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" #include "core/hle/service/btm/btm.h" #include "core/hle/service/service.h" @@ -58,12 +58,14 @@ public: RegisterHandlers(functions); auto& kernel = system.Kernel(); - scan_event = Kernel::KWritableEvent::CreateEventPair(kernel, "IBtmUserCore:ScanEvent"); - connection_event = - Kernel::KWritableEvent::CreateEventPair(kernel, "IBtmUserCore:ConnectionEvent"); - service_discovery = - Kernel::KWritableEvent::CreateEventPair(kernel, "IBtmUserCore:Discovery"); - config_event = Kernel::KWritableEvent::CreateEventPair(kernel, "IBtmUserCore:ConfigEvent"); + scan_event = Kernel::KEvent::Create(kernel, "IBtmUserCore:ScanEvent"); + scan_event->Initialize(); + connection_event = Kernel::KEvent::Create(kernel, "IBtmUserCore:ConnectionEvent"); + connection_event->Initialize(); + service_discovery = Kernel::KEvent::Create(kernel, "IBtmUserCore:Discovery"); + service_discovery->Initialize(); + config_event = Kernel::KEvent::Create(kernel, "IBtmUserCore:ConfigEvent"); + config_event->Initialize(); } private: @@ -72,7 +74,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(scan_event.readable); + rb.PushCopyObjects(scan_event->GetReadableEvent()); } void AcquireBleConnectionEvent(Kernel::HLERequestContext& ctx) { @@ -80,7 +82,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(connection_event.readable); + rb.PushCopyObjects(connection_event->GetReadableEvent()); } void AcquireBleServiceDiscoveryEvent(Kernel::HLERequestContext& ctx) { @@ -88,7 +90,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(service_discovery.readable); + rb.PushCopyObjects(service_discovery->GetReadableEvent()); } void AcquireBleMtuConfigEvent(Kernel::HLERequestContext& ctx) { @@ -96,13 +98,13 @@ private: IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(config_event.readable); + rb.PushCopyObjects(config_event->GetReadableEvent()); } - Kernel::EventPair scan_event; - Kernel::EventPair connection_event; - Kernel::EventPair service_discovery; - Kernel::EventPair config_event; + std::shared_ptr scan_event; + std::shared_ptr connection_event; + std::shared_ptr service_discovery; + std::shared_ptr config_event; }; class BTM_USR final : public ServiceFramework { diff --git a/src/core/hle/service/friend/friend.cpp b/src/core/hle/service/friend/friend.cpp index fa6cc74ed0..72a877d683 100644 --- a/src/core/hle/service/friend/friend.cpp +++ b/src/core/hle/service/friend/friend.cpp @@ -7,6 +7,7 @@ #include "common/uuid.h" #include "core/core.h" #include "core/hle/ipc_helpers.h" +#include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_writable_event.h" #include "core/hle/service/friend/errors.h" @@ -183,8 +184,9 @@ public: RegisterHandlers(functions); - notification_event = Kernel::KWritableEvent::CreateEventPair( - system.Kernel(), "INotificationService:NotifyEvent"); + notification_event = + Kernel::KEvent::Create(system.Kernel(), "INotificationService:NotifyEvent"); + notification_event->Initialize(); } private: @@ -193,7 +195,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(notification_event.readable); + rb.PushCopyObjects(notification_event->GetReadableEvent()); } void Clear(Kernel::HLERequestContext& ctx) { @@ -258,7 +260,7 @@ private: }; Common::UUID uuid{Common::INVALID_UUID}; - Kernel::EventPair notification_event; + std::shared_ptr notification_event; std::queue notifications; States states{}; }; diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 35f93da4f3..5794f417c2 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp @@ -12,6 +12,7 @@ #include "core/core.h" #include "core/core_timing.h" #include "core/frontend/input.h" +#include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" @@ -153,7 +154,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) { const auto controller_type = connected_controllers[controller_idx].type; auto& controller = shared_memory_entries[controller_idx]; if (controller_type == NPadControllerType::None) { - styleset_changed_events[controller_idx].writable->Signal(); + styleset_changed_events[controller_idx]->GetWritableEvent()->Signal(); return; } controller.joy_styles.raw = 0; // Zero out @@ -233,8 +234,9 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) { void Controller_NPad::OnInit() { auto& kernel = system.Kernel(); for (std::size_t i = 0; i < styleset_changed_events.size(); ++i) { - styleset_changed_events[i] = Kernel::KWritableEvent::CreateEventPair( - kernel, fmt::format("npad:NpadStyleSetChanged_{}", i)); + styleset_changed_events[i] = + Kernel::KEvent::Create(kernel, fmt::format("npad:NpadStyleSetChanged_{}", i)); + styleset_changed_events[i]->Initialize(); } if (!IsControllerActivated()) { @@ -875,11 +877,11 @@ bool Controller_NPad::IsVibrationDeviceMounted(const DeviceHandle& vibration_dev std::shared_ptr Controller_NPad::GetStyleSetChangedEvent( u32 npad_id) const { const auto& styleset_event = styleset_changed_events[NPadIdToIndex(npad_id)]; - return styleset_event.readable; + return styleset_event->GetReadableEvent(); } void Controller_NPad::SignalStyleSetChangedEvent(u32 npad_id) const { - styleset_changed_events[NPadIdToIndex(npad_id)].writable->Signal(); + styleset_changed_events[NPadIdToIndex(npad_id)]->GetWritableEvent()->Signal(); } void Controller_NPad::AddNewControllerAt(NPadControllerType controller, std::size_t npad_index) { diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 110b56cc4a..1a65b19f5e 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h @@ -9,11 +9,15 @@ #include "common/bit_field.h" #include "common/common_types.h" #include "core/frontend/input.h" -#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/object.h" #include "core/hle/service/hid/controllers/controller_base.h" #include "core/settings.h" +namespace Kernel { +class KEvent; +class KReadableEvent; +} // namespace Kernel + namespace Service::HID { constexpr u32 NPAD_HANDHELD = 32; @@ -452,7 +456,7 @@ private: // NpadCommunicationMode is unknown, default value is 1 NpadCommunicationMode communication_mode{NpadCommunicationMode::Unknown1}; // Each controller should have their own styleset changed event - std::array styleset_changed_events; + std::array, 10> styleset_changed_events; std::array, 10> last_vibration_timepoints; std::array, 10> latest_vibration_values{}; bool permit_vibration_session_enabled{false}; diff --git a/src/core/hle/service/nfp/nfp.cpp b/src/core/hle/service/nfp/nfp.cpp index 0e53aa848e..5d6d256965 100644 --- a/src/core/hle/service/nfp/nfp.cpp +++ b/src/core/hle/service/nfp/nfp.cpp @@ -8,6 +8,7 @@ #include "common/logging/log.h" #include "core/core.h" #include "core/hle/ipc_helpers.h" +#include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_thread.h" #include "core/hle/kernel/k_writable_event.h" @@ -25,7 +26,8 @@ Module::Interface::Interface(std::shared_ptr module_, Core::System& syst const char* name) : ServiceFramework{system_, name}, module{std::move(module_)} { auto& kernel = system.Kernel(); - nfc_tag_load = Kernel::KWritableEvent::CreateEventPair(kernel, "IUser:NFCTagDetected"); + nfc_tag_load = Kernel::KEvent::Create(kernel, "IUser:NFCTagDetected"); + nfc_tag_load->Initialize(); } Module::Interface::~Interface() = default; @@ -64,9 +66,10 @@ public: RegisterHandlers(functions); auto& kernel = system.Kernel(); - deactivate_event = Kernel::KWritableEvent::CreateEventPair(kernel, "IUser:DeactivateEvent"); - availability_change_event = - Kernel::KWritableEvent::CreateEventPair(kernel, "IUser:AvailabilityChangeEvent"); + deactivate_event = Kernel::KEvent::Create(kernel, "IUser:DeactivateEvent"); + deactivate_event->Initialize(); + availability_change_event = Kernel::KEvent::Create(kernel, "IUser:AvailabilityChangeEvent"); + availability_change_event->Initialize(); } private: @@ -164,7 +167,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(deactivate_event.readable); + rb.PushCopyObjects(deactivate_event->GetReadableEvent()); } void StopDetection(Kernel::HLERequestContext& ctx) { @@ -173,7 +176,7 @@ private: switch (device_state) { case DeviceState::TagFound: case DeviceState::TagNearby: - deactivate_event.writable->Signal(); + deactivate_event->GetWritableEvent()->Signal(); device_state = DeviceState::Initialized; break; case DeviceState::SearchingForTag: @@ -262,7 +265,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(availability_change_event.readable); + rb.PushCopyObjects(availability_change_event->GetReadableEvent()); } void GetRegisterInfo(Kernel::HLERequestContext& ctx) { @@ -316,8 +319,8 @@ private: const u32 npad_id{0}; // Player 1 controller State state{State::NonInitialized}; DeviceState device_state{DeviceState::Initialized}; - Kernel::EventPair deactivate_event; - Kernel::EventPair availability_change_event; + std::shared_ptr deactivate_event; + std::shared_ptr availability_change_event; const Module::Interface& nfp_interface; }; @@ -336,12 +339,12 @@ bool Module::Interface::LoadAmiibo(const std::vector& buffer) { } std::memcpy(&amiibo, buffer.data(), sizeof(amiibo)); - nfc_tag_load.writable->Signal(); + nfc_tag_load->GetWritableEvent()->Signal(); return true; } const std::shared_ptr& Module::Interface::GetNFCEvent() const { - return nfc_tag_load.readable; + return nfc_tag_load->GetReadableEvent(); } const Module::Interface::AmiiboFile& Module::Interface::GetAmiiboBuffer() const { diff --git a/src/core/hle/service/nfp/nfp.h b/src/core/hle/service/nfp/nfp.h index 9ed5ed0f7a..c465517603 100644 --- a/src/core/hle/service/nfp/nfp.h +++ b/src/core/hle/service/nfp/nfp.h @@ -6,10 +6,13 @@ #include #include -#include "core/hle/kernel/k_readable_event.h" -#include "core/hle/kernel/k_writable_event.h" + #include "core/hle/service/service.h" +namespace Kernel { +class KEvent; +} + namespace Service::NFP { class Module final { @@ -39,7 +42,7 @@ public: const AmiiboFile& GetAmiiboBuffer() const; private: - Kernel::EventPair nfc_tag_load{}; + std::shared_ptr nfc_tag_load; AmiiboFile amiibo{}; protected: diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp index 6cb778140c..afb3342d66 100644 --- a/src/core/hle/service/nifm/nifm.cpp +++ b/src/core/hle/service/nifm/nifm.cpp @@ -4,8 +4,8 @@ #include "core/core.h" #include "core/hle/ipc_helpers.h" +#include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_readable_event.h" -#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" #include "core/hle/service/nifm/nifm.h" #include "core/hle/service/service.h" @@ -158,8 +158,11 @@ public: RegisterHandlers(functions); auto& kernel = system.Kernel(); - event1 = Kernel::KWritableEvent::CreateEventPair(kernel, "IRequest:Event1"); - event2 = Kernel::KWritableEvent::CreateEventPair(kernel, "IRequest:Event2"); + + event1 = Kernel::KEvent::Create(kernel, "IRequest:Event1"); + event1->Initialize(); + event2 = Kernel::KEvent::Create(kernel, "IRequest:Event2"); + event2->Initialize(); } private: @@ -195,7 +198,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 2}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(event1.readable, event2.readable); + rb.PushCopyObjects(event1->GetReadableEvent(), event2->GetReadableEvent()); } void Cancel(Kernel::HLERequestContext& ctx) { @@ -226,7 +229,7 @@ private: rb.Push(0); } - Kernel::EventPair event1, event2; + std::shared_ptr event1, event2; }; class INetworkProfile final : public ServiceFramework { diff --git a/src/core/hle/service/nim/nim.cpp b/src/core/hle/service/nim/nim.cpp index f180221fe5..f3be0b878f 100644 --- a/src/core/hle/service/nim/nim.cpp +++ b/src/core/hle/service/nim/nim.cpp @@ -6,6 +6,7 @@ #include #include "core/core.h" #include "core/hle/ipc_helpers.h" +#include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" @@ -301,17 +302,18 @@ public: RegisterHandlers(functions); auto& kernel = system.Kernel(); - finished_event = Kernel::KWritableEvent::CreateEventPair( - kernel, "IEnsureNetworkClockAvailabilityService:FinishEvent"); + finished_event = + Kernel::KEvent::Create(kernel, "IEnsureNetworkClockAvailabilityService:FinishEvent"); + finished_event->Initialize(); } private: - Kernel::EventPair finished_event; + std::shared_ptr finished_event; void StartTask(Kernel::HLERequestContext& ctx) { // No need to connect to the internet, just finish the task straight away. LOG_DEBUG(Service_NIM, "called"); - finished_event.writable->Signal(); + finished_event->GetWritableEvent()->Signal(); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); } @@ -321,7 +323,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(finished_event.readable); + rb.PushCopyObjects(finished_event->GetReadableEvent()); } void GetResult(Kernel::HLERequestContext& ctx) { @@ -333,7 +335,7 @@ private: void Cancel(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_NIM, "called"); - finished_event.writable->Clear(); + finished_event->GetWritableEvent()->Clear(); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); } diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp index 695e2fb10e..f6129ef102 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp @@ -8,7 +8,7 @@ #include "common/assert.h" #include "common/logging/log.h" #include "core/core.h" -#include "core/hle/kernel/k_readable_event.h" +#include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_writable_event.h" #include "core/hle/service/nvdrv/devices/nvhost_ctrl.h" #include "video_core/gpu.h" @@ -103,14 +103,14 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector& input, std::vector // This is mostly to take into account unimplemented features. As synced // gpu is always synced. if (!gpu.IsAsync()) { - event.event.writable->Signal(); + event.event->GetWritableEvent()->Signal(); return NvResult::Success; } auto lock = gpu.LockSync(); const u32 current_syncpoint_value = event.fence.value; const s32 diff = current_syncpoint_value - params.threshold; if (diff >= 0) { - event.event.writable->Signal(); + event.event->GetWritableEvent()->Signal(); params.value = current_syncpoint_value; std::memcpy(output.data(), ¶ms, sizeof(params)); return NvResult::Success; @@ -137,7 +137,7 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector& input, std::vector params.value = ((params.syncpt_id & 0xfff) << 16) | 0x10000000; } params.value |= event_id; - event.event.writable->Clear(); + event.event->GetWritableEvent()->Clear(); gpu.RegisterSyncptInterrupt(params.syncpt_id, target_value); std::memcpy(output.data(), ¶ms, sizeof(params)); return NvResult::Timeout; diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp index b6c4c85e0e..abba801129 100644 --- a/src/core/hle/service/nvdrv/nvdrv.cpp +++ b/src/core/hle/service/nvdrv/nvdrv.cpp @@ -7,6 +7,7 @@ #include #include "core/core.h" #include "core/hle/ipc_helpers.h" +#include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_writable_event.h" #include "core/hle/service/nvdrv/devices/nvdevice.h" @@ -42,7 +43,8 @@ Module::Module(Core::System& system) : syncpoint_manager{system.GPU()} { auto& kernel = system.Kernel(); for (u32 i = 0; i < MaxNvEvents; i++) { std::string event_label = fmt::format("NVDRV::NvEvent_{}", i); - events_interface.events[i] = {Kernel::KWritableEvent::CreateEventPair(kernel, event_label)}; + events_interface.events[i] = {Kernel::KEvent::Create(kernel, std::move(event_label))}; + events_interface.events[i].event->Initialize(); events_interface.status[i] = EventState::Free; events_interface.registered[i] = false; } @@ -166,17 +168,17 @@ void Module::SignalSyncpt(const u32 syncpoint_id, const u32 value) { if (events_interface.assigned_syncpt[i] == syncpoint_id && events_interface.assigned_value[i] == value) { events_interface.LiberateEvent(i); - events_interface.events[i].event.writable->Signal(); + events_interface.events[i].event->GetWritableEvent()->Signal(); } } } std::shared_ptr Module::GetEvent(const u32 event_id) const { - return events_interface.events[event_id].event.readable; + return events_interface.events[event_id].event->GetReadableEvent(); } std::shared_ptr Module::GetEventWriteable(const u32 event_id) const { - return events_interface.events[event_id].event.writable; + return events_interface.events[event_id].event->GetWritableEvent(); } } // namespace Service::Nvidia diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h index 0d638e521a..53719aadda 100644 --- a/src/core/hle/service/nvdrv/nvdrv.h +++ b/src/core/hle/service/nvdrv/nvdrv.h @@ -7,8 +7,8 @@ #include #include #include + #include "common/common_types.h" -#include "core/hle/kernel/k_writable_event.h" #include "core/hle/service/nvdrv/nvdata.h" #include "core/hle/service/nvdrv/syncpoint_manager.h" #include "core/hle/service/service.h" @@ -17,6 +17,10 @@ namespace Core { class System; } +namespace Kernel { +class KEvent; +} + namespace Service::NVFlinger { class NVFlinger; } @@ -31,7 +35,7 @@ class nvdevice; /// Represents an Nvidia event struct NvEvent { - Kernel::EventPair event; + std::shared_ptr event; Fence fence{}; }; diff --git a/src/core/hle/service/nvflinger/buffer_queue.cpp b/src/core/hle/service/nvflinger/buffer_queue.cpp index 805f178aa3..7842a82ed7 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.cpp +++ b/src/core/hle/service/nvflinger/buffer_queue.cpp @@ -7,7 +7,7 @@ #include "common/assert.h" #include "common/logging/log.h" #include "core/core.h" -#include "core/hle/kernel/k_readable_event.h" +#include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" #include "core/hle/service/nvflinger/buffer_queue.h" @@ -16,7 +16,8 @@ namespace Service::NVFlinger { BufferQueue::BufferQueue(Kernel::KernelCore& kernel, u32 id, u64 layer_id) : id(id), layer_id(layer_id) { - buffer_wait_event = Kernel::KWritableEvent::CreateEventPair(kernel, "BufferQueue NativeHandle"); + buffer_wait_event = Kernel::KEvent::Create(kernel, "BufferQueue:WaitEvent"); + buffer_wait_event->Initialize(); } BufferQueue::~BufferQueue() = default; @@ -41,7 +42,7 @@ void BufferQueue::SetPreallocatedBuffer(u32 slot, const IGBPBuffer& igbp_buffer) .multi_fence = {}, }; - buffer_wait_event.writable->Signal(); + buffer_wait_event->GetWritableEvent()->Signal(); } std::optional> BufferQueue::DequeueBuffer(u32 width, @@ -119,7 +120,7 @@ void BufferQueue::CancelBuffer(u32 slot, const Service::Nvidia::MultiFence& mult } free_buffers_condition.notify_one(); - buffer_wait_event.writable->Signal(); + buffer_wait_event->GetWritableEvent()->Signal(); } std::optional> BufferQueue::AcquireBuffer() { @@ -154,7 +155,7 @@ void BufferQueue::ReleaseBuffer(u32 slot) { } free_buffers_condition.notify_one(); - buffer_wait_event.writable->Signal(); + buffer_wait_event->GetWritableEvent()->Signal(); } void BufferQueue::Connect() { @@ -169,7 +170,7 @@ void BufferQueue::Disconnect() { std::unique_lock lock{queue_sequence_mutex}; queue_sequence.clear(); } - buffer_wait_event.writable->Signal(); + buffer_wait_event->GetWritableEvent()->Signal(); is_connect = false; free_buffers_condition.notify_one(); } @@ -189,11 +190,11 @@ u32 BufferQueue::Query(QueryType type) { } std::shared_ptr BufferQueue::GetWritableBufferWaitEvent() const { - return buffer_wait_event.writable; + return buffer_wait_event->GetWritableEvent(); } std::shared_ptr BufferQueue::GetBufferWaitEvent() const { - return buffer_wait_event.readable; + return buffer_wait_event->GetReadableEvent(); } } // namespace Service::NVFlinger diff --git a/src/core/hle/service/nvflinger/buffer_queue.h b/src/core/hle/service/nvflinger/buffer_queue.h index 4de1441133..163fa4c54e 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.h +++ b/src/core/hle/service/nvflinger/buffer_queue.h @@ -13,13 +13,15 @@ #include "common/common_funcs.h" #include "common/math_util.h" #include "common/swap.h" -#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/object.h" #include "core/hle/service/nvdrv/nvdata.h" namespace Kernel { class KernelCore; -} +class KEvent; +class KReadableEvent; +class KWritableEvent; +} // namespace Kernel namespace Service::NVFlinger { @@ -127,7 +129,7 @@ private: std::list free_buffers; std::array buffers; std::list queue_sequence; - Kernel::EventPair buffer_wait_event; + std::shared_ptr buffer_wait_event; std::mutex free_buffers_mutex; std::condition_variable free_buffers_condition; diff --git a/src/core/hle/service/ptm/psm.cpp b/src/core/hle/service/ptm/psm.cpp index c1f7b33f19..26ed52273d 100644 --- a/src/core/hle/service/ptm/psm.cpp +++ b/src/core/hle/service/ptm/psm.cpp @@ -7,6 +7,7 @@ #include "common/logging/log.h" #include "core/core.h" #include "core/hle/ipc_helpers.h" +#include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" @@ -31,27 +32,28 @@ public: RegisterHandlers(functions); - state_change_event = Kernel::KWritableEvent::CreateEventPair( - system_.Kernel(), "IPsmSession::state_change_event"); + state_change_event = + Kernel::KEvent::Create(system_.Kernel(), "IPsmSession::state_change_event"); + state_change_event->Initialize(); } ~IPsmSession() override = default; void SignalChargerTypeChanged() { if (should_signal && should_signal_charger_type) { - state_change_event.writable->Signal(); + state_change_event->GetWritableEvent()->Signal(); } } void SignalPowerSupplyChanged() { if (should_signal && should_signal_power_supply) { - state_change_event.writable->Signal(); + state_change_event->GetWritableEvent()->Signal(); } } void SignalBatteryVoltageStateChanged() { if (should_signal && should_signal_battery_voltage) { - state_change_event.writable->Signal(); + state_change_event->GetWritableEvent()->Signal(); } } @@ -63,7 +65,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(state_change_event.readable); + rb.PushCopyObjects(state_change_event->GetReadableEvent()); } void UnbindStateChangeEvent(Kernel::HLERequestContext& ctx) { @@ -112,7 +114,7 @@ private: bool should_signal_power_supply{}; bool should_signal_battery_voltage{}; bool should_signal{}; - Kernel::EventPair state_change_event; + std::shared_ptr state_change_event; }; class PSM final : public ServiceFramework { diff --git a/src/core/hle/service/time/standard_user_system_clock_core.cpp b/src/core/hle/service/time/standard_user_system_clock_core.cpp index 9362350a05..b9faa474e9 100644 --- a/src/core/hle/service/time/standard_user_system_clock_core.cpp +++ b/src/core/hle/service/time/standard_user_system_clock_core.cpp @@ -4,7 +4,7 @@ #include "common/assert.h" #include "core/core.h" -#include "core/hle/kernel/k_writable_event.h" +#include "core/hle/kernel/k_event.h" #include "core/hle/service/time/standard_local_system_clock_core.h" #include "core/hle/service/time/standard_network_system_clock_core.h" #include "core/hle/service/time/standard_user_system_clock_core.h" @@ -18,8 +18,10 @@ StandardUserSystemClockCore::StandardUserSystemClockCore( local_system_clock_core{local_system_clock_core}, network_system_clock_core{network_system_clock_core}, auto_correction_enabled{}, auto_correction_time{SteadyClockTimePoint::GetRandom()}, - auto_correction_event{Kernel::KWritableEvent::CreateEventPair( - system.Kernel(), "StandardUserSystemClockCore:AutoCorrectionEvent")} {} + auto_correction_event{Kernel::KEvent::Create( + system.Kernel(), "StandardUserSystemClockCore:AutoCorrectionEvent")} { + auto_correction_event->Initialize(); +} ResultCode StandardUserSystemClockCore::SetAutomaticCorrectionEnabled(Core::System& system, bool value) { diff --git a/src/core/hle/service/time/standard_user_system_clock_core.h b/src/core/hle/service/time/standard_user_system_clock_core.h index 30d3a2a0d3..aac44d72fe 100644 --- a/src/core/hle/service/time/standard_user_system_clock_core.h +++ b/src/core/hle/service/time/standard_user_system_clock_core.h @@ -4,7 +4,6 @@ #pragma once -#include "core/hle/kernel/k_writable_event.h" #include "core/hle/service/time/clock_types.h" #include "core/hle/service/time/system_clock_core.h" @@ -12,6 +11,10 @@ namespace Core { class System; } +namespace Kernel { +class KEvent; +} + namespace Service::Time::Clock { class StandardLocalSystemClockCore; @@ -51,7 +54,7 @@ private: StandardNetworkSystemClockCore& network_system_clock_core; bool auto_correction_enabled{}; SteadyClockTimePoint auto_correction_time; - Kernel::EventPair auto_correction_event; + std::shared_ptr auto_correction_event; }; } // namespace Service::Time::Clock diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp index 02d5287a99..7f42aa4a02 100644 --- a/src/core/hle/service/vi/display/vi_display.cpp +++ b/src/core/hle/service/vi/display/vi_display.cpp @@ -9,7 +9,9 @@ #include "common/assert.h" #include "core/core.h" +#include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_readable_event.h" +#include "core/hle/kernel/k_writable_event.h" #include "core/hle/service/vi/display/vi_display.h" #include "core/hle/service/vi/layer/vi_layer.h" @@ -17,8 +19,8 @@ namespace Service::VI { Display::Display(u64 id, std::string name, Core::System& system) : id{id}, name{std::move(name)} { auto& kernel = system.Kernel(); - vsync_event = - Kernel::KWritableEvent::CreateEventPair(kernel, fmt::format("Display VSync Event {}", id)); + vsync_event = Kernel::KEvent::Create(kernel, fmt::format("Display VSync Event {}", id)); + vsync_event->Initialize(); } Display::~Display() = default; @@ -32,11 +34,11 @@ const Layer& Display::GetLayer(std::size_t index) const { } std::shared_ptr Display::GetVSyncEvent() const { - return vsync_event.readable; + return vsync_event->GetReadableEvent(); } void Display::SignalVSyncEvent() { - vsync_event.writable->Signal(); + vsync_event->GetWritableEvent()->Signal(); } void Display::CreateLayer(u64 id, NVFlinger::BufferQueue& buffer_queue) { diff --git a/src/core/hle/service/vi/display/vi_display.h b/src/core/hle/service/vi/display/vi_display.h index b576c9cf20..931c898f69 100644 --- a/src/core/hle/service/vi/display/vi_display.h +++ b/src/core/hle/service/vi/display/vi_display.h @@ -9,7 +9,10 @@ #include #include "common/common_types.h" -#include "core/hle/kernel/k_writable_event.h" + +namespace Kernel { +class KEvent; +} namespace Service::NVFlinger { class BufferQueue; @@ -99,7 +102,7 @@ private: std::string name; std::vector> layers; - Kernel::EventPair vsync_event; + std::shared_ptr vsync_event; }; } // namespace Service::VI From 18175c71edf90eeb73c6f47745b2bad32e4a1478 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 31 Jan 2021 16:54:10 -0800 Subject: [PATCH 07/10] common: scope_exit: Add a cancellable ScopeExit macro. --- src/common/scope_exit.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/common/scope_exit.h b/src/common/scope_exit.h index fa46cb3945..35dac3a8f9 100644 --- a/src/common/scope_exit.h +++ b/src/common/scope_exit.h @@ -49,3 +49,9 @@ ScopeExitHelper ScopeExit(Func&& func) { * \endcode */ #define SCOPE_EXIT(body) auto CONCAT2(scope_exit_helper_, __LINE__) = detail::ScopeExit([&]() body) + +/** + * This macro is similar to SCOPE_EXIT, except the object is caller managed. This is intended to be + * used when the caller might want to cancel the ScopeExit. + */ +#define SCOPE_GUARD(body) detail::ScopeExit([&]() body) From eba3c59a611962a1b019a5edfbc16c8d6db58be9 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 31 Jan 2021 16:55:11 -0800 Subject: [PATCH 08/10] hle: kernel: svc: Cleanup KEvent/KReadableEvent/KWritableEvent SVCs. --- src/core/hle/kernel/k_readable_event.cpp | 1 - src/core/hle/kernel/process.cpp | 19 ++- src/core/hle/kernel/process.h | 2 +- src/core/hle/kernel/svc.cpp | 149 +++++++++++++---------- src/core/hle/kernel/svc_results.h | 1 + 5 files changed, 96 insertions(+), 76 deletions(-) diff --git a/src/core/hle/kernel/k_readable_event.cpp b/src/core/hle/kernel/k_readable_event.cpp index 0fa895c560..cd15aa5292 100644 --- a/src/core/hle/kernel/k_readable_event.cpp +++ b/src/core/hle/kernel/k_readable_event.cpp @@ -49,7 +49,6 @@ ResultCode KReadableEvent::Reset() { R_UNLESS_NOLOG(is_signaled, Svc::ResultInvalidState); is_signaled = false; - return RESULT_SUCCESS; } diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index afdb27c548..2286b292dc 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp @@ -23,6 +23,7 @@ #include "core/hle/kernel/memory/page_table.h" #include "core/hle/kernel/memory/slab_heap.h" #include "core/hle/kernel/process.h" +#include "core/hle/kernel/svc_results.h" #include "core/hle/lock.h" #include "core/memory.h" #include "core/settings.h" @@ -241,18 +242,16 @@ void Process::UnregisterThread(const KThread* thread) { thread_list.remove(thread); } -ResultCode Process::ClearSignalState() { - KScopedSchedulerLock lock(system.Kernel()); - if (status == ProcessStatus::Exited) { - LOG_ERROR(Kernel, "called on a terminated process instance."); - return ERR_INVALID_STATE; - } +ResultCode Process::Reset() { + // Lock the process and the scheduler. + KScopedLightLock lk(state_lock); + KScopedSchedulerLock sl{kernel}; - if (!is_signaled) { - LOG_ERROR(Kernel, "called on a process instance that isn't signaled."); - return ERR_INVALID_STATE; - } + // Validate that we're in a state that we can reset. + R_UNLESS(status != ProcessStatus::Exited, Svc::ResultInvalidState); + R_UNLESS(is_signaled, Svc::ResultInvalidState); + // Clear signaled. is_signaled = false; return RESULT_SUCCESS; } diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index c8af76ce8b..320b0f3474 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h @@ -312,7 +312,7 @@ public: /// @pre The process must be in a signaled state. If this is called on a /// process instance that is not signaled, ERR_INVALID_STATE will be /// returned. - ResultCode ClearSignalState(); + ResultCode Reset(); /** * Loads process-specifics configuration info with metadata provided diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 9d036f45dd..edf208eff3 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -14,6 +14,7 @@ #include "common/fiber.h" #include "common/logging/log.h" #include "common/microprofile.h" +#include "common/scope_exit.h" #include "common/string_util.h" #include "core/arm/exclusive_monitor.h" #include "core/core.h" @@ -1726,20 +1727,28 @@ static ResultCode CloseHandle32(Core::System& system, Handle handle) { static ResultCode ResetSignal(Core::System& system, Handle handle) { LOG_DEBUG(Kernel_SVC, "called handle 0x{:08X}", handle); + // Get the current handle table. const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); - auto event = handle_table.Get(handle); - if (event) { - return event->Reset(); + // Try to reset as readable event. + { + auto readable_event = handle_table.Get(handle); + if (readable_event) { + return readable_event->Reset(); + } } - auto process = handle_table.Get(handle); - if (process) { - return process->ClearSignalState(); + // Try to reset as process. + { + auto process = handle_table.Get(handle); + if (process) { + return process->Reset(); + } } - LOG_ERROR(Kernel_SVC, "Invalid handle (0x{:08X})", handle); - return ERR_INVALID_HANDLE; + LOG_ERROR(Kernel_SVC, "invalid handle (0x{:08X})", handle); + + return Svc::ResultInvalidHandle; } static ResultCode ResetSignal32(Core::System& system, Handle handle) { @@ -1867,80 +1876,92 @@ static ResultCode SetThreadCoreMask32(Core::System& system, Handle thread_handle return SetThreadCoreMask(system, thread_handle, core_id, affinity_mask); } -static ResultCode CreateEvent(Core::System& system, Handle* write_handle, Handle* read_handle) { +static ResultCode SignalEvent(Core::System& system, Handle event_handle) { + LOG_DEBUG(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle); + + // Get the current handle table. + const HandleTable& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); + + // Get the writable event. + auto writable_event = handle_table.Get(event_handle); + R_UNLESS(writable_event, Svc::ResultInvalidHandle); + + return writable_event->Signal(); +} + +static ResultCode SignalEvent32(Core::System& system, Handle event_handle) { + return SignalEvent(system, event_handle); +} + +static ResultCode ClearEvent(Core::System& system, Handle event_handle) { + LOG_TRACE(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle); + + // Get the current handle table. + const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); + + // Try to clear the writable event. + { + auto writable_event = handle_table.Get(event_handle); + if (writable_event) { + return writable_event->Clear(); + } + } + + // Try to clear the readable event. + { + auto readable_event = handle_table.Get(event_handle); + if (readable_event) { + return readable_event->Clear(); + } + } + + LOG_ERROR(Kernel_SVC, "Event handle does not exist, event_handle=0x{:08X}", event_handle); + + return Svc::ResultInvalidHandle; +} + +static ResultCode ClearEvent32(Core::System& system, Handle event_handle) { + return ClearEvent(system, event_handle); +} + +static ResultCode CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) { LOG_DEBUG(Kernel_SVC, "called"); + // Get the kernel reference and handle table. auto& kernel = system.Kernel(); - const auto event = KEvent::Create(kernel, "CreateEvent"); - event->Initialize(); - HandleTable& handle_table = kernel.CurrentProcess()->GetHandleTable(); + // Create a new event. + const auto event = KEvent::Create(kernel, "CreateEvent"); + R_UNLESS(event != nullptr, Svc::ResultOutOfResource); + + // Initialize the event. + event->Initialize(); + + // Add the writable event to the handle table. const auto write_create_result = handle_table.Create(event->GetWritableEvent()); if (write_create_result.Failed()) { return write_create_result.Code(); } - *write_handle = *write_create_result; + *out_write = *write_create_result; + // Add the writable event to the handle table. + auto handle_guard = SCOPE_GUARD({ handle_table.Close(*write_create_result); }); + + // Add the readable event to the handle table. const auto read_create_result = handle_table.Create(event->GetReadableEvent()); if (read_create_result.Failed()) { - handle_table.Close(*write_create_result); return read_create_result.Code(); } - *read_handle = *read_create_result; + *out_read = *read_create_result; - LOG_DEBUG(Kernel_SVC, - "successful. Writable event handle=0x{:08X}, Readable event handle=0x{:08X}", - *write_create_result, *read_create_result); + // We succeeded. + handle_guard.Cancel(); return RESULT_SUCCESS; } -static ResultCode CreateEvent32(Core::System& system, Handle* write_handle, Handle* read_handle) { - return CreateEvent(system, write_handle, read_handle); -} - -static ResultCode ClearEvent(Core::System& system, Handle handle) { - LOG_TRACE(Kernel_SVC, "called, event=0x{:08X}", handle); - - const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); - - auto writable_event = handle_table.Get(handle); - if (writable_event) { - writable_event->Clear(); - return RESULT_SUCCESS; - } - - auto readable_event = handle_table.Get(handle); - if (readable_event) { - readable_event->Clear(); - return RESULT_SUCCESS; - } - - LOG_ERROR(Kernel_SVC, "Event handle does not exist, handle=0x{:08X}", handle); - return ERR_INVALID_HANDLE; -} - -static ResultCode ClearEvent32(Core::System& system, Handle handle) { - return ClearEvent(system, handle); -} - -static ResultCode SignalEvent(Core::System& system, Handle handle) { - LOG_DEBUG(Kernel_SVC, "called. Handle=0x{:08X}", handle); - - HandleTable& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); - auto writable_event = handle_table.Get(handle); - - if (!writable_event) { - LOG_ERROR(Kernel_SVC, "Non-existent writable event handle used (0x{:08X})", handle); - return ERR_INVALID_HANDLE; - } - - writable_event->Signal(); - return RESULT_SUCCESS; -} - -static ResultCode SignalEvent32(Core::System& system, Handle handle) { - return SignalEvent(system, handle); +static ResultCode CreateEvent32(Core::System& system, Handle* out_write, Handle* out_read) { + return CreateEvent(system, out_write, out_read); } static ResultCode GetProcessInfo(Core::System& system, u64* out, Handle process_handle, u32 type) { diff --git a/src/core/hle/kernel/svc_results.h b/src/core/hle/kernel/svc_results.h index 7b897fbce3..204cd989d8 100644 --- a/src/core/hle/kernel/svc_results.h +++ b/src/core/hle/kernel/svc_results.h @@ -11,6 +11,7 @@ namespace Kernel::Svc { constexpr ResultCode ResultNoSynchronizationObject{ErrorModule::Kernel, 57}; constexpr ResultCode ResultTerminationRequested{ErrorModule::Kernel, 59}; constexpr ResultCode ResultInvalidAddress{ErrorModule::Kernel, 102}; +constexpr ResultCode ResultOutOfResource{ErrorModule::Kernel, 103}; constexpr ResultCode ResultInvalidCurrentMemory{ErrorModule::Kernel, 106}; constexpr ResultCode ResultInvalidPriority{ErrorModule::Kernel, 112}; constexpr ResultCode ResultInvalidCoreId{ErrorModule::Kernel, 113}; From 546af643404f8de456ac8e39262ad40c5d4e6659 Mon Sep 17 00:00:00 2001 From: bunnei Date: Wed, 3 Feb 2021 18:03:53 -0800 Subject: [PATCH 09/10] hle: kernel: KAddressArbiter: Remove noisy error log. --- src/core/hle/kernel/k_address_arbiter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/hle/kernel/k_address_arbiter.cpp b/src/core/hle/kernel/k_address_arbiter.cpp index 9309376ccd..affc048528 100644 --- a/src/core/hle/kernel/k_address_arbiter.cpp +++ b/src/core/hle/kernel/k_address_arbiter.cpp @@ -120,7 +120,7 @@ ResultCode KAddressArbiter::SignalAndIncrementIfEqual(VAddr addr, s32 value, s32 s32 user_value{}; R_UNLESS(UpdateIfEqual(system, std::addressof(user_value), addr, value, value + 1), Svc::ResultInvalidCurrentMemory); - R_UNLESS(user_value == value, Svc::ResultInvalidState); + R_UNLESS_NOLOG(user_value == value, Svc::ResultInvalidState); auto it = thread_tree.nfind_light({addr, -1}); while ((it != thread_tree.end()) && (count <= 0 || num_waiters < count) && From ea4f62615e71cd2b680517b7609928ed0abf216d Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 4 Feb 2021 16:56:57 -0800 Subject: [PATCH 10/10] hle: kernel: Drop R_UNLESS_NOLOG in favor of expanded if-statement. --- src/common/common_funcs.h | 8 -------- src/core/hle/kernel/k_address_arbiter.cpp | 10 ++++++++-- src/core/hle/kernel/k_readable_event.cpp | 4 +++- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index cd3207a037..71b64e32a3 100644 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h @@ -104,14 +104,6 @@ __declspec(dllimport) void __stdcall DebugBreak(void); } \ } -/// Evaluates a boolean expression, and returns a result unless that expression is true. -#define R_UNLESS_NOLOG(expr, res) \ - { \ - if (!(expr)) { \ - return res; \ - } \ - } - #define R_SUCCEEDED(res) (res.IsSuccess()) /// Evaluates an expression that returns a result, and returns the result if it would fail. diff --git a/src/core/hle/kernel/k_address_arbiter.cpp b/src/core/hle/kernel/k_address_arbiter.cpp index affc048528..f2f497dc4d 100644 --- a/src/core/hle/kernel/k_address_arbiter.cpp +++ b/src/core/hle/kernel/k_address_arbiter.cpp @@ -120,7 +120,10 @@ ResultCode KAddressArbiter::SignalAndIncrementIfEqual(VAddr addr, s32 value, s32 s32 user_value{}; R_UNLESS(UpdateIfEqual(system, std::addressof(user_value), addr, value, value + 1), Svc::ResultInvalidCurrentMemory); - R_UNLESS_NOLOG(user_value == value, Svc::ResultInvalidState); + + if (user_value != value) { + return Svc::ResultInvalidState; + } auto it = thread_tree.nfind_light({addr, -1}); while ((it != thread_tree.end()) && (count <= 0 || num_waiters < count) && @@ -211,7 +214,10 @@ ResultCode KAddressArbiter::SignalAndModifyByWaitingCountIfEqual(VAddr addr, s32 } R_UNLESS(succeeded, Svc::ResultInvalidCurrentMemory); - R_UNLESS_NOLOG(user_value == value, Svc::ResultInvalidState); + + if (user_value != value) { + return Svc::ResultInvalidState; + } while ((it != thread_tree.end()) && (count <= 0 || num_waiters < count) && (it->GetAddressArbiterKey() == addr)) { diff --git a/src/core/hle/kernel/k_readable_event.cpp b/src/core/hle/kernel/k_readable_event.cpp index cd15aa5292..d8a42dbaf9 100644 --- a/src/core/hle/kernel/k_readable_event.cpp +++ b/src/core/hle/kernel/k_readable_event.cpp @@ -46,7 +46,9 @@ ResultCode KReadableEvent::Clear() { ResultCode KReadableEvent::Reset() { KScopedSchedulerLock lk{kernel}; - R_UNLESS_NOLOG(is_signaled, Svc::ResultInvalidState); + if (!is_signaled) { + return Svc::ResultInvalidState; + } is_signaled = false; return RESULT_SUCCESS;