diff options
Diffstat (limited to 'src/core/hle/service/am')
-rw-r--r-- | src/core/hle/service/am/am.cpp | 38 | ||||
-rw-r--r-- | src/core/hle/service/am/am.h | 16 | ||||
-rw-r--r-- | src/core/hle/service/am/applets/applets.cpp | 31 | ||||
-rw-r--r-- | src/core/hle/service/am/applets/applets.h | 17 |
4 files changed, 57 insertions, 45 deletions
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index d595c37b0..43c91e521 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -9,9 +9,11 @@ #include "audio_core/audio_renderer.h" #include "core/core.h" #include "core/hle/ipc_helpers.h" -#include "core/hle/kernel/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/shared_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" @@ -208,8 +210,8 @@ ISelfController::ISelfController(std::shared_ptr<NVFlinger::NVFlinger> nvflinger RegisterHandlers(functions); auto& kernel = Core::System::GetInstance().Kernel(); - launchable_event = - Kernel::Event::Create(kernel, Kernel::ResetType::Sticky, "ISelfController:LaunchableEvent"); + launchable_event = Kernel::WritableEvent::CreateRegisteredEventPair( + kernel, Kernel::ResetType::Sticky, "ISelfController:LaunchableEvent"); } ISelfController::~ISelfController() = default; @@ -299,8 +301,7 @@ void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(launchable_event); -} + rb.PushCopyObjects(event->second); void ISelfController::SetScreenShotImageOrientation(Kernel::HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); @@ -348,20 +349,26 @@ void ISelfController::GetIdleTimeDetectionExtension(Kernel::HLERequestContext& c AppletMessageQueue::AppletMessageQueue() { auto& kernel = Core::System::GetInstance().Kernel(); - on_new_message = Kernel::Event::Create(kernel, Kernel::ResetType::Sticky, - "AMMessageQueue:OnMessageRecieved"); - on_operation_mode_changed = Kernel::Event::Create(kernel, Kernel::ResetType::OneShot, - "AMMessageQueue:OperationModeChanged"); + on_new_message = Kernel::WritableEvent::CreateRegisteredEventPair( + kernel, Kernel::ResetType::Sticky, "AMMessageQueue:OnMessageRecieved"); + on_operation_mode_changed = Kernel::WritableEvent::CreateRegisteredEventPair( + kernel, Kernel::ResetType::OneShot, "AMMessageQueue:OperationModeChanged"); } AppletMessageQueue::~AppletMessageQueue() = default; -const Kernel::SharedPtr<Kernel::Event>& AppletMessageQueue::GetMesssageRecieveEvent() const { - return on_new_message; +const Kernel::SharedPtr<Kernel::ReadableEvent>& AppletMessageQueue::GetMesssageRecieveEvent() + const { + const auto& event{ + Core::System::GetInstance().Kernel().FindNamedEvent("AMMessageQueue:OnMessageRecieved")}; + return event->second; } -const Kernel::SharedPtr<Kernel::Event>& AppletMessageQueue::GetOperationModeChangedEvent() const { - return on_operation_mode_changed; +const Kernel::SharedPtr<Kernel::ReadableEvent>& AppletMessageQueue::GetOperationModeChangedEvent() + const { + const auto& event{ + Core::System::GetInstance().Kernel().FindNamedEvent("AMMessageQueue:OperationModeChanged")}; + return event->second; } void AppletMessageQueue::PushMessage(AppletMessage msg) { @@ -426,9 +433,6 @@ ICommonStateGetter::ICommonStateGetter(std::shared_ptr<AppletMessageQueue> msg_q // clang-format on RegisterHandlers(functions); - - auto& kernel = Core::System::GetInstance().Kernel(); - event = Kernel::Event::Create(kernel, Kernel::ResetType::OneShot, "ICommonStateGetter:Event"); } ICommonStateGetter::~ICommonStateGetter() = default; @@ -564,8 +568,8 @@ private: void GetAppletStateChangedEvent(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_AM, "called"); + applet->GetBroker().SignalStateChanged(); const auto event = applet->GetBroker().GetStateChangedEvent(); - event->Signal(); IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index 44c1bcde5..ef90b0702 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -9,8 +9,9 @@ #include "core/hle/service/service.h" namespace Kernel { -class Event; -} +class ReadableEvent; +class WritableEvent; +} // namespace Kernel namespace Service { namespace NVFlinger { @@ -52,8 +53,8 @@ public: AppletMessageQueue(); ~AppletMessageQueue(); - const Kernel::SharedPtr<Kernel::Event>& GetMesssageRecieveEvent() const; - const Kernel::SharedPtr<Kernel::Event>& GetOperationModeChangedEvent() const; + const Kernel::SharedPtr<Kernel::ReadableEvent>& GetMesssageRecieveEvent() const; + const Kernel::SharedPtr<Kernel::ReadableEvent>& GetOperationModeChangedEvent() const; void PushMessage(AppletMessage msg); AppletMessage PopMessage(); std::size_t GetMessageCount() const; @@ -61,8 +62,8 @@ public: private: std::queue<AppletMessage> messages; - Kernel::SharedPtr<Kernel::Event> on_new_message; - Kernel::SharedPtr<Kernel::Event> on_operation_mode_changed; + Kernel::SharedPtr<Kernel::WritableEvent> on_new_message; + Kernel::SharedPtr<Kernel::WritableEvent> on_operation_mode_changed; }; class IWindowController final : public ServiceFramework<IWindowController> { @@ -122,7 +123,7 @@ private: void GetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx); std::shared_ptr<NVFlinger::NVFlinger> nvflinger; - Kernel::SharedPtr<Kernel::Event> launchable_event; + Kernel::SharedPtr<Kernel::WritableEvent> launchable_event; u32 idle_time_detection_extension = 0; }; @@ -151,7 +152,6 @@ private: void GetBootMode(Kernel::HLERequestContext& ctx); void GetDefaultDisplayResolution(Kernel::HLERequestContext& ctx); - Kernel::SharedPtr<Kernel::Event> event; std::shared_ptr<AppletMessageQueue> msg_queue; }; diff --git a/src/core/hle/service/am/applets/applets.cpp b/src/core/hle/service/am/applets/applets.cpp index becbadd06..494205322 100644 --- a/src/core/hle/service/am/applets/applets.cpp +++ b/src/core/hle/service/am/applets/applets.cpp @@ -5,8 +5,9 @@ #include <cstring> #include "common/assert.h" #include "core/core.h" -#include "core/hle/kernel/event.h" +#include "core/hle/kernel/readable_event.h" #include "core/hle/kernel/server_port.h" +#include "core/hle/kernel/writable_event.h" #include "core/hle/service/am/am.h" #include "core/hle/service/am/applets/applets.h" @@ -14,11 +15,11 @@ namespace Service::AM::Applets { AppletDataBroker::AppletDataBroker() { auto& kernel = Core::System::GetInstance().Kernel(); - state_changed_event = Kernel::Event::Create(kernel, Kernel::ResetType::OneShot, - "ILibraryAppletAccessor:StateChangedEvent"); - pop_out_data_event = Kernel::Event::Create(kernel, Kernel::ResetType::OneShot, - "ILibraryAppletAccessor:PopDataOutEvent"); - pop_interactive_out_data_event = Kernel::Event::Create( + state_changed_event = Kernel::WritableEvent::CreateRegisteredEventPair( + kernel, Kernel::ResetType::OneShot, "ILibraryAppletAccessor:StateChangedEvent"); + pop_out_data_event = Kernel::WritableEvent::CreateRegisteredEventPair( + kernel, Kernel::ResetType::OneShot, "ILibraryAppletAccessor:PopDataOutEvent"); + pop_interactive_out_data_event = Kernel::WritableEvent::CreateRegisteredEventPair( kernel, Kernel::ResetType::OneShot, "ILibraryAppletAccessor:PopInteractiveDataOutEvent"); } @@ -82,16 +83,22 @@ void AppletDataBroker::SignalStateChanged() const { state_changed_event->Signal(); } -Kernel::SharedPtr<Kernel::Event> AppletDataBroker::GetNormalDataEvent() const { - return pop_out_data_event; +Kernel::SharedPtr<Kernel::ReadableEvent> AppletDataBroker::GetNormalDataEvent() const { + const auto& event{Core::System::GetInstance().Kernel().FindNamedEvent( + "ILibraryAppletAccessor:PopDataOutEvent")}; + return event->second; } -Kernel::SharedPtr<Kernel::Event> AppletDataBroker::GetInteractiveDataEvent() const { - return pop_interactive_out_data_event; +Kernel::SharedPtr<Kernel::ReadableEvent> AppletDataBroker::GetInteractiveDataEvent() const { + const auto& event{Core::System::GetInstance().Kernel().FindNamedEvent( + "ILibraryAppletAccessor:PopInteractiveDataOutEvent")}; + return event->second; } -Kernel::SharedPtr<Kernel::Event> AppletDataBroker::GetStateChangedEvent() const { - return state_changed_event; +Kernel::SharedPtr<Kernel::ReadableEvent> AppletDataBroker::GetStateChangedEvent() const { + const auto& event{Core::System::GetInstance().Kernel().FindNamedEvent( + "ILibraryAppletAccessor:StateChangedEvent")}; + return event->second; } Applet::Applet() = default; diff --git a/src/core/hle/service/am/applets/applets.h b/src/core/hle/service/am/applets/applets.h index f65ea119c..5cd6232cc 100644 --- a/src/core/hle/service/am/applets/applets.h +++ b/src/core/hle/service/am/applets/applets.h @@ -12,8 +12,9 @@ union ResultCode; namespace Kernel { -class Event; -} +class ReadableEvent; +class WritableEvent; +} // namespace Kernel namespace Service::AM { @@ -40,9 +41,9 @@ public: void SignalStateChanged() const; - Kernel::SharedPtr<Kernel::Event> GetNormalDataEvent() const; - Kernel::SharedPtr<Kernel::Event> GetInteractiveDataEvent() const; - Kernel::SharedPtr<Kernel::Event> GetStateChangedEvent() const; + Kernel::SharedPtr<Kernel::ReadableEvent> GetNormalDataEvent() const; + Kernel::SharedPtr<Kernel::ReadableEvent> GetInteractiveDataEvent() const; + Kernel::SharedPtr<Kernel::ReadableEvent> GetStateChangedEvent() const; private: // Queues are named from applet's perspective @@ -59,13 +60,13 @@ private: // PopInteractiveDataToGame and PushInteractiveDataFromApplet std::queue<std::unique_ptr<IStorage>> out_interactive_channel; - Kernel::SharedPtr<Kernel::Event> state_changed_event; + Kernel::SharedPtr<Kernel::WritableEvent> state_changed_event; // Signaled on PushNormalDataFromApplet - Kernel::SharedPtr<Kernel::Event> pop_out_data_event; + Kernel::SharedPtr<Kernel::WritableEvent> pop_out_data_event; // Signaled on PushInteractiveDataFromApplet - Kernel::SharedPtr<Kernel::Event> pop_interactive_out_data_event; + Kernel::SharedPtr<Kernel::WritableEvent> pop_interactive_out_data_event; }; class Applet { |