diff options
| author | 2021-04-04 00:56:09 -0700 | |
|---|---|---|
| committer | 2021-05-05 16:40:50 -0700 | |
| commit | addc0bf0379e075786048921bede6e089552a6db (patch) | |
| tree | 7fa8819b52db29e1b354410441dd8f2438e2ed4a /src | |
| parent | hle: kernel: Migrate KSharedMemory to KAutoObject. (diff) | |
| download | yuzu-addc0bf0379e075786048921bede6e089552a6db.tar.gz yuzu-addc0bf0379e075786048921bede6e089552a6db.tar.xz yuzu-addc0bf0379e075786048921bede6e089552a6db.zip | |
hle: kernel: Migrate KEvent to KAutoObject.
Diffstat (limited to 'src')
37 files changed, 269 insertions, 266 deletions
diff --git a/src/core/hle/kernel/handle_table.cpp b/src/core/hle/kernel/handle_table.cpp index 427c6fc1b..58c49460f 100644 --- a/src/core/hle/kernel/handle_table.cpp +++ b/src/core/hle/kernel/handle_table.cpp | |||
| @@ -53,6 +53,7 @@ ResultVal<Handle> HandleTable::Create(Object* obj) { | |||
| 53 | switch (obj->GetHandleType()) { | 53 | switch (obj->GetHandleType()) { |
| 54 | case HandleType::SharedMemory: | 54 | case HandleType::SharedMemory: |
| 55 | case HandleType::Thread: | 55 | case HandleType::Thread: |
| 56 | case HandleType::Event: | ||
| 56 | case HandleType::Process: { | 57 | case HandleType::Process: { |
| 57 | Handle handle{}; | 58 | Handle handle{}; |
| 58 | Add(&handle, reinterpret_cast<KAutoObject*>(obj), {}); | 59 | Add(&handle, reinterpret_cast<KAutoObject*>(obj), {}); |
diff --git a/src/core/hle/kernel/init/init_slab_setup.cpp b/src/core/hle/kernel/init/init_slab_setup.cpp index eb9c8e2e4..b292f7db2 100644 --- a/src/core/hle/kernel/init/init_slab_setup.cpp +++ b/src/core/hle/kernel/init/init_slab_setup.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "core/core.h" | 9 | #include "core/core.h" |
| 10 | #include "core/hardware_properties.h" | 10 | #include "core/hardware_properties.h" |
| 11 | #include "core/hle/kernel/init/init_slab_setup.h" | 11 | #include "core/hle/kernel/init/init_slab_setup.h" |
| 12 | #include "core/hle/kernel/k_event.h" | ||
| 12 | #include "core/hle/kernel/k_memory_layout.h" | 13 | #include "core/hle/kernel/k_memory_layout.h" |
| 13 | #include "core/hle/kernel/k_memory_manager.h" | 14 | #include "core/hle/kernel/k_memory_manager.h" |
| 14 | #include "core/hle/kernel/k_shared_memory.h" | 15 | #include "core/hle/kernel/k_shared_memory.h" |
| @@ -25,6 +26,7 @@ namespace Kernel::Init { | |||
| 25 | #define FOREACH_SLAB_TYPE(HANDLER, ...) \ | 26 | #define FOREACH_SLAB_TYPE(HANDLER, ...) \ |
| 26 | HANDLER(Process, (SLAB_COUNT(Process)), ##__VA_ARGS__) \ | 27 | HANDLER(Process, (SLAB_COUNT(Process)), ##__VA_ARGS__) \ |
| 27 | HANDLER(KThread, (SLAB_COUNT(KThread)), ##__VA_ARGS__) \ | 28 | HANDLER(KThread, (SLAB_COUNT(KThread)), ##__VA_ARGS__) \ |
| 29 | HANDLER(KEvent, (SLAB_COUNT(KEvent)), ##__VA_ARGS__) \ | ||
| 28 | HANDLER(KSharedMemory, (SLAB_COUNT(KSharedMemory)), ##__VA_ARGS__) | 30 | HANDLER(KSharedMemory, (SLAB_COUNT(KSharedMemory)), ##__VA_ARGS__) |
| 29 | 31 | ||
| 30 | namespace { | 32 | namespace { |
diff --git a/src/core/hle/kernel/k_event.cpp b/src/core/hle/kernel/k_event.cpp index bb2fa4ad5..bc4a79cc8 100644 --- a/src/core/hle/kernel/k_event.cpp +++ b/src/core/hle/kernel/k_event.cpp | |||
| @@ -4,29 +4,53 @@ | |||
| 4 | 4 | ||
| 5 | #include "core/hle/kernel/k_event.h" | 5 | #include "core/hle/kernel/k_event.h" |
| 6 | #include "core/hle/kernel/k_readable_event.h" | 6 | #include "core/hle/kernel/k_readable_event.h" |
| 7 | #include "core/hle/kernel/k_resource_limit.h" | ||
| 7 | #include "core/hle/kernel/k_writable_event.h" | 8 | #include "core/hle/kernel/k_writable_event.h" |
| 9 | #include "core/hle/kernel/process.h" | ||
| 8 | 10 | ||
| 9 | namespace Kernel { | 11 | namespace Kernel { |
| 10 | 12 | ||
| 11 | KEvent::KEvent(KernelCore& kernel, std::string&& name) : Object{kernel, std::move(name)} {} | 13 | KEvent::KEvent(KernelCore& kernel) : KAutoObjectWithSlabHeapAndContainer{kernel} {} |
| 12 | 14 | ||
| 13 | KEvent::~KEvent() = default; | 15 | KEvent::~KEvent() = default; |
| 14 | 16 | ||
| 15 | std::shared_ptr<KEvent> KEvent::Create(KernelCore& kernel, std::string&& name) { | 17 | void KEvent::Initialize(std::string&& name_) { |
| 16 | return std::make_shared<KEvent>(kernel, std::move(name)); | 18 | // Increment reference count. |
| 17 | } | 19 | // Because reference count is one on creation, this will result |
| 20 | // in a reference count of two. Thus, when both readable and | ||
| 21 | // writable events are closed this object will be destroyed. | ||
| 22 | Open(); | ||
| 18 | 23 | ||
| 19 | void KEvent::Initialize() { | ||
| 20 | // Create our sub events. | 24 | // Create our sub events. |
| 21 | readable_event = std::make_shared<KReadableEvent>(kernel, GetName() + ":Readable"); | 25 | readable_event = std::make_shared<KReadableEvent>(kernel, name_ + ":Readable"); |
| 22 | writable_event = std::make_shared<KWritableEvent>(kernel, GetName() + ":Writable"); | 26 | writable_event = std::make_shared<KWritableEvent>(kernel, name_ + ":Writable"); |
| 23 | 27 | ||
| 24 | // Initialize our sub sessions. | 28 | // Initialize our sub sessions. |
| 25 | readable_event->Initialize(this); | 29 | readable_event->Initialize(this); |
| 26 | writable_event->Initialize(this); | 30 | writable_event->Initialize(this); |
| 27 | 31 | ||
| 32 | // Set our owner process. | ||
| 33 | owner = kernel.CurrentProcess(); | ||
| 34 | if (owner) { | ||
| 35 | owner->Open(); | ||
| 36 | } | ||
| 37 | |||
| 28 | // Mark initialized. | 38 | // Mark initialized. |
| 39 | name = std::move(name_); | ||
| 29 | initialized = true; | 40 | initialized = true; |
| 30 | } | 41 | } |
| 31 | 42 | ||
| 43 | void KEvent::Finalize() { | ||
| 44 | KAutoObjectWithSlabHeapAndContainer<KEvent, KAutoObjectWithList>::Finalize(); | ||
| 45 | } | ||
| 46 | |||
| 47 | void KEvent::PostDestroy(uintptr_t arg) { | ||
| 48 | // Release the event count resource the owner process holds. | ||
| 49 | Process* owner = reinterpret_cast<Process*>(arg); | ||
| 50 | if (owner) { | ||
| 51 | owner->GetResourceLimit()->Release(LimitableResource::Events, 1); | ||
| 52 | owner->Close(); | ||
| 53 | } | ||
| 54 | } | ||
| 55 | |||
| 32 | } // namespace Kernel | 56 | } // namespace Kernel |
diff --git a/src/core/hle/kernel/k_event.h b/src/core/hle/kernel/k_event.h index ec6894b16..97ec0ea9c 100644 --- a/src/core/hle/kernel/k_event.h +++ b/src/core/hle/kernel/k_event.h | |||
| @@ -4,24 +4,34 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include "core/hle/kernel/object.h" | 7 | #include "core/hle/kernel/slab_helpers.h" |
| 8 | 8 | ||
| 9 | namespace Kernel { | 9 | namespace Kernel { |
| 10 | 10 | ||
| 11 | class KernelCore; | 11 | class KernelCore; |
| 12 | class KReadableEvent; | 12 | class KReadableEvent; |
| 13 | class KWritableEvent; | 13 | class KWritableEvent; |
| 14 | class Process; | ||
| 15 | |||
| 16 | class KEvent final : public KAutoObjectWithSlabHeapAndContainer<KEvent, KAutoObjectWithList> { | ||
| 17 | KERNEL_AUTOOBJECT_TRAITS(KEvent, KAutoObject); | ||
| 14 | 18 | ||
| 15 | class KEvent final : public Object { | ||
| 16 | public: | 19 | public: |
| 17 | explicit KEvent(KernelCore& kernel, std::string&& name); | 20 | explicit KEvent(KernelCore& kernel); |
| 18 | ~KEvent() override; | 21 | ~KEvent() override; |
| 19 | 22 | ||
| 20 | static std::shared_ptr<KEvent> Create(KernelCore& kernel, std::string&& name); | 23 | void Initialize(std::string&& name); |
| 24 | |||
| 25 | virtual void Finalize() override; | ||
| 21 | 26 | ||
| 22 | void Initialize(); | 27 | virtual bool IsInitialized() const override { |
| 28 | return initialized; | ||
| 29 | } | ||
| 30 | virtual uintptr_t GetPostDestroyArgument() const override { | ||
| 31 | return reinterpret_cast<uintptr_t>(owner); | ||
| 32 | } | ||
| 23 | 33 | ||
| 24 | void Finalize() override {} | 34 | static void PostDestroy(uintptr_t arg); |
| 25 | 35 | ||
| 26 | std::string GetTypeName() const override { | 36 | std::string GetTypeName() const override { |
| 27 | return "KEvent"; | 37 | return "KEvent"; |
| @@ -51,6 +61,7 @@ public: | |||
| 51 | private: | 61 | private: |
| 52 | std::shared_ptr<KReadableEvent> readable_event; | 62 | std::shared_ptr<KReadableEvent> readable_event; |
| 53 | std::shared_ptr<KWritableEvent> writable_event; | 63 | std::shared_ptr<KWritableEvent> writable_event; |
| 64 | Process* owner{}; | ||
| 54 | bool initialized{}; | 65 | bool initialized{}; |
| 55 | }; | 66 | }; |
| 56 | 67 | ||
diff --git a/src/core/hle/kernel/object.h b/src/core/hle/kernel/object.h index 5c14aa46f..03443b947 100644 --- a/src/core/hle/kernel/object.h +++ b/src/core/hle/kernel/object.h | |||
| @@ -71,6 +71,8 @@ protected: | |||
| 71 | 71 | ||
| 72 | private: | 72 | private: |
| 73 | std::atomic<u32> object_id{0}; | 73 | std::atomic<u32> object_id{0}; |
| 74 | |||
| 75 | protected: | ||
| 74 | std::string name; | 76 | std::string name; |
| 75 | }; | 77 | }; |
| 76 | 78 | ||
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 17d63658a..b143a51c7 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -1953,14 +1953,11 @@ static ResultCode CreateEvent(Core::System& system, Handle* out_write, Handle* o | |||
| 1953 | HandleTable& handle_table = kernel.CurrentProcess()->GetHandleTable(); | 1953 | HandleTable& handle_table = kernel.CurrentProcess()->GetHandleTable(); |
| 1954 | 1954 | ||
| 1955 | // Create a new event. | 1955 | // Create a new event. |
| 1956 | const auto event = KEvent::Create(kernel, "CreateEvent"); | 1956 | KEvent* event = KEvent::CreateWithKernel(kernel); |
| 1957 | if (!event) { | 1957 | R_UNLESS(event != nullptr, ResultOutOfResource); |
| 1958 | LOG_ERROR(Kernel_SVC, "Unable to create new events. Event creation limit reached."); | ||
| 1959 | return ResultOutOfResource; | ||
| 1960 | } | ||
| 1961 | 1958 | ||
| 1962 | // Initialize the event. | 1959 | // Initialize the event. |
| 1963 | event->Initialize(); | 1960 | event->Initialize("CreateEvent"); |
| 1964 | 1961 | ||
| 1965 | // Add the writable event to the handle table. | 1962 | // Add the writable event to the handle table. |
| 1966 | const auto write_create_result = handle_table.Create(event->GetWritableEvent().get()); | 1963 | const auto write_create_result = handle_table.Create(event->GetWritableEvent().get()); |
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 7be94446a..3800c65ad 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp | |||
| @@ -253,7 +253,8 @@ IDebugFunctions::IDebugFunctions(Core::System& system_) | |||
| 253 | IDebugFunctions::~IDebugFunctions() = default; | 253 | IDebugFunctions::~IDebugFunctions() = default; |
| 254 | 254 | ||
| 255 | ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nvflinger_) | 255 | ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nvflinger_) |
| 256 | : ServiceFramework{system_, "ISelfController"}, nvflinger{nvflinger_} { | 256 | : ServiceFramework{system_, "ISelfController"}, nvflinger{nvflinger_}, |
| 257 | launchable_event{system.Kernel()}, accumulated_suspended_tick_changed_event{system.Kernel()} { | ||
| 257 | // clang-format off | 258 | // clang-format off |
| 258 | static const FunctionInfo functions[] = { | 259 | static const FunctionInfo functions[] = { |
| 259 | {0, &ISelfController::Exit, "Exit"}, | 260 | {0, &ISelfController::Exit, "Exit"}, |
| @@ -306,19 +307,17 @@ ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nv | |||
| 306 | 307 | ||
| 307 | RegisterHandlers(functions); | 308 | RegisterHandlers(functions); |
| 308 | 309 | ||
| 309 | auto& kernel = system.Kernel(); | 310 | launchable_event.Initialize("ISelfController:LaunchableEvent"); |
| 310 | launchable_event = Kernel::KEvent::Create(kernel, "ISelfController:LaunchableEvent"); | ||
| 311 | launchable_event->Initialize(); | ||
| 312 | 311 | ||
| 313 | // This event is created by AM on the first time GetAccumulatedSuspendedTickChangedEvent() is | 312 | // This event is created by AM on the first time GetAccumulatedSuspendedTickChangedEvent() is |
| 314 | // called. Yuzu can just create it unconditionally, since it doesn't need to support multiple | 313 | // called. Yuzu can just create it unconditionally, since it doesn't need to support multiple |
| 315 | // ISelfControllers. The event is signaled on creation, and on transition from suspended -> not | 314 | // ISelfControllers. The event is signaled on creation, and on transition from suspended -> not |
| 316 | // suspended if the event has previously been created by a call to | 315 | // suspended if the event has previously been created by a call to |
| 317 | // GetAccumulatedSuspendedTickChangedEvent. | 316 | // GetAccumulatedSuspendedTickChangedEvent. |
| 318 | accumulated_suspended_tick_changed_event = | 317 | |
| 319 | Kernel::KEvent::Create(kernel, "ISelfController:AccumulatedSuspendedTickChangedEvent"); | 318 | accumulated_suspended_tick_changed_event.Initialize( |
| 320 | accumulated_suspended_tick_changed_event->Initialize(); | 319 | "ISelfController:AccumulatedSuspendedTickChangedEvent"); |
| 321 | accumulated_suspended_tick_changed_event->GetWritableEvent()->Signal(); | 320 | accumulated_suspended_tick_changed_event.GetWritableEvent()->Signal(); |
| 322 | } | 321 | } |
| 323 | 322 | ||
| 324 | ISelfController::~ISelfController() = default; | 323 | ISelfController::~ISelfController() = default; |
| @@ -377,11 +376,11 @@ void ISelfController::LeaveFatalSection(Kernel::HLERequestContext& ctx) { | |||
| 377 | void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx) { | 376 | void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx) { |
| 378 | LOG_WARNING(Service_AM, "(STUBBED) called"); | 377 | LOG_WARNING(Service_AM, "(STUBBED) called"); |
| 379 | 378 | ||
| 380 | launchable_event->GetWritableEvent()->Signal(); | 379 | launchable_event.GetWritableEvent()->Signal(); |
| 381 | 380 | ||
| 382 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 381 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 383 | rb.Push(RESULT_SUCCESS); | 382 | rb.Push(RESULT_SUCCESS); |
| 384 | rb.PushCopyObjects(launchable_event->GetReadableEvent()); | 383 | rb.PushCopyObjects(launchable_event.GetReadableEvent()); |
| 385 | } | 384 | } |
| 386 | 385 | ||
| 387 | void ISelfController::SetScreenShotPermission(Kernel::HLERequestContext& ctx) { | 386 | void ISelfController::SetScreenShotPermission(Kernel::HLERequestContext& ctx) { |
| @@ -560,7 +559,7 @@ void ISelfController::GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequest | |||
| 560 | 559 | ||
| 561 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 560 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 562 | rb.Push(RESULT_SUCCESS); | 561 | rb.Push(RESULT_SUCCESS); |
| 563 | rb.PushCopyObjects(accumulated_suspended_tick_changed_event->GetReadableEvent()); | 562 | rb.PushCopyObjects(accumulated_suspended_tick_changed_event.GetReadableEvent()); |
| 564 | } | 563 | } |
| 565 | 564 | ||
| 566 | void ISelfController::SetAlbumImageTakenNotificationEnabled(Kernel::HLERequestContext& ctx) { | 565 | void ISelfController::SetAlbumImageTakenNotificationEnabled(Kernel::HLERequestContext& ctx) { |
| @@ -578,38 +577,36 @@ void ISelfController::SetAlbumImageTakenNotificationEnabled(Kernel::HLERequestCo | |||
| 578 | rb.Push(RESULT_SUCCESS); | 577 | rb.Push(RESULT_SUCCESS); |
| 579 | } | 578 | } |
| 580 | 579 | ||
| 581 | AppletMessageQueue::AppletMessageQueue(Kernel::KernelCore& kernel) { | 580 | AppletMessageQueue::AppletMessageQueue(Kernel::KernelCore& kernel) |
| 582 | on_new_message = Kernel::KEvent::Create(kernel, "AMMessageQueue:OnMessageReceived"); | 581 | : on_new_message{kernel}, on_operation_mode_changed{kernel} { |
| 583 | on_new_message->Initialize(); | 582 | on_new_message.Initialize("AMMessageQueue:OnMessageReceived"); |
| 584 | on_operation_mode_changed = | 583 | on_operation_mode_changed.Initialize("AMMessageQueue:OperationModeChanged"); |
| 585 | Kernel::KEvent::Create(kernel, "AMMessageQueue:OperationModeChanged"); | ||
| 586 | on_operation_mode_changed->Initialize(); | ||
| 587 | } | 584 | } |
| 588 | 585 | ||
| 589 | AppletMessageQueue::~AppletMessageQueue() = default; | 586 | AppletMessageQueue::~AppletMessageQueue() = default; |
| 590 | 587 | ||
| 591 | Kernel::KReadableEvent* AppletMessageQueue::GetMessageReceiveEvent() const { | 588 | Kernel::KReadableEvent* AppletMessageQueue::GetMessageReceiveEvent() const { |
| 592 | return on_new_message->GetReadableEvent(); | 589 | return on_new_message.GetReadableEvent().get(); |
| 593 | } | 590 | } |
| 594 | 591 | ||
| 595 | Kernel::KReadableEvent* AppletMessageQueue::GetOperationModeChangedEvent() const { | 592 | Kernel::KReadableEvent* AppletMessageQueue::GetOperationModeChangedEvent() const { |
| 596 | return on_operation_mode_changed->GetReadableEvent(); | 593 | return on_operation_mode_changed.GetReadableEvent().get(); |
| 597 | } | 594 | } |
| 598 | 595 | ||
| 599 | void AppletMessageQueue::PushMessage(AppletMessage msg) { | 596 | void AppletMessageQueue::PushMessage(AppletMessage msg) { |
| 600 | messages.push(msg); | 597 | messages.push(msg); |
| 601 | on_new_message->GetWritableEvent()->Signal(); | 598 | on_new_message.GetWritableEvent()->Signal(); |
| 602 | } | 599 | } |
| 603 | 600 | ||
| 604 | AppletMessageQueue::AppletMessage AppletMessageQueue::PopMessage() { | 601 | AppletMessageQueue::AppletMessage AppletMessageQueue::PopMessage() { |
| 605 | if (messages.empty()) { | 602 | if (messages.empty()) { |
| 606 | on_new_message->GetWritableEvent()->Clear(); | 603 | on_new_message.GetWritableEvent()->Clear(); |
| 607 | return AppletMessage::NoMessage; | 604 | return AppletMessage::NoMessage; |
| 608 | } | 605 | } |
| 609 | auto msg = messages.front(); | 606 | auto msg = messages.front(); |
| 610 | messages.pop(); | 607 | messages.pop(); |
| 611 | if (messages.empty()) { | 608 | if (messages.empty()) { |
| 612 | on_new_message->GetWritableEvent()->Clear(); | 609 | on_new_message.GetWritableEvent()->Clear(); |
| 613 | } | 610 | } |
| 614 | return msg; | 611 | return msg; |
| 615 | } | 612 | } |
| @@ -629,7 +626,7 @@ void AppletMessageQueue::FocusStateChanged() { | |||
| 629 | void AppletMessageQueue::OperationModeChanged() { | 626 | void AppletMessageQueue::OperationModeChanged() { |
| 630 | PushMessage(AppletMessage::OperationModeChanged); | 627 | PushMessage(AppletMessage::OperationModeChanged); |
| 631 | PushMessage(AppletMessage::PerformanceModeChanged); | 628 | PushMessage(AppletMessage::PerformanceModeChanged); |
| 632 | on_operation_mode_changed->GetWritableEvent()->Signal(); | 629 | on_operation_mode_changed.GetWritableEvent()->Signal(); |
| 633 | } | 630 | } |
| 634 | 631 | ||
| 635 | ICommonStateGetter::ICommonStateGetter(Core::System& system_, | 632 | ICommonStateGetter::ICommonStateGetter(Core::System& system_, |
| @@ -1212,16 +1209,16 @@ void ILibraryAppletCreator::CreateTransferMemoryStorage(Kernel::HLERequestContex | |||
| 1212 | } | 1209 | } |
| 1213 | 1210 | ||
| 1214 | auto transfer_mem = | 1211 | auto transfer_mem = |
| 1215 | system.CurrentProcess()->GetHandleTable().Get<Kernel::TransferMemory>(handle); | 1212 | system.CurrentProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(handle); |
| 1216 | 1213 | ||
| 1217 | if (transfer_mem == nullptr) { | 1214 | if (transfer_mem.IsNull()) { |
| 1218 | LOG_ERROR(Service_AM, "transfer_mem is a nullptr for handle={:08X}", handle); | 1215 | LOG_ERROR(Service_AM, "transfer_mem is a nullptr for handle={:08X}", handle); |
| 1219 | IPC::ResponseBuilder rb{ctx, 2}; | 1216 | IPC::ResponseBuilder rb{ctx, 2}; |
| 1220 | rb.Push(RESULT_UNKNOWN); | 1217 | rb.Push(RESULT_UNKNOWN); |
| 1221 | return; | 1218 | return; |
| 1222 | } | 1219 | } |
| 1223 | 1220 | ||
| 1224 | const u8* const mem_begin = transfer_mem->GetPointer(); | 1221 | const u8* const mem_begin = system.Memory().GetPointer(transfer_mem->GetSourceAddress()); |
| 1225 | const u8* const mem_end = mem_begin + transfer_mem->GetSize(); | 1222 | const u8* const mem_end = mem_begin + transfer_mem->GetSize(); |
| 1226 | std::vector<u8> memory{mem_begin, mem_end}; | 1223 | std::vector<u8> memory{mem_begin, mem_end}; |
| 1227 | 1224 | ||
| @@ -1265,7 +1262,9 @@ void ILibraryAppletCreator::CreateHandleStorage(Kernel::HLERequestContext& ctx) | |||
| 1265 | } | 1262 | } |
| 1266 | 1263 | ||
| 1267 | IApplicationFunctions::IApplicationFunctions(Core::System& system_) | 1264 | IApplicationFunctions::IApplicationFunctions(Core::System& system_) |
| 1268 | : ServiceFramework{system_, "IApplicationFunctions"} { | 1265 | : ServiceFramework{system_, "IApplicationFunctions"}, gpu_error_detected_event{system.Kernel()}, |
| 1266 | friend_invitation_storage_channel_event{system.Kernel()}, | ||
| 1267 | health_warning_disappeared_system_event{system.Kernel()} { | ||
| 1269 | // clang-format off | 1268 | // clang-format off |
| 1270 | static const FunctionInfo functions[] = { | 1269 | static const FunctionInfo functions[] = { |
| 1271 | {1, &IApplicationFunctions::PopLaunchParameter, "PopLaunchParameter"}, | 1270 | {1, &IApplicationFunctions::PopLaunchParameter, "PopLaunchParameter"}, |
| @@ -1334,15 +1333,11 @@ IApplicationFunctions::IApplicationFunctions(Core::System& system_) | |||
| 1334 | RegisterHandlers(functions); | 1333 | RegisterHandlers(functions); |
| 1335 | 1334 | ||
| 1336 | auto& kernel = system.Kernel(); | 1335 | auto& kernel = system.Kernel(); |
| 1337 | gpu_error_detected_event = | 1336 | gpu_error_detected_event.Initialize("IApplicationFunctions:GpuErrorDetectedSystemEvent"); |
| 1338 | Kernel::KEvent::Create(kernel, "IApplicationFunctions:GpuErrorDetectedSystemEvent"); | 1337 | friend_invitation_storage_channel_event.Initialize( |
| 1339 | gpu_error_detected_event->Initialize(); | 1338 | "IApplicationFunctions:FriendInvitationStorageChannelEvent"); |
| 1340 | friend_invitation_storage_channel_event = | 1339 | health_warning_disappeared_system_event.Initialize( |
| 1341 | Kernel::KEvent::Create(kernel, "IApplicationFunctions:FriendInvitationStorageChannelEvent"); | 1340 | "IApplicationFunctions:HealthWarningDisappearedSystemEvent"); |
| 1342 | friend_invitation_storage_channel_event->Initialize(); | ||
| 1343 | health_warning_disappeared_system_event = | ||
| 1344 | Kernel::KEvent::Create(kernel, "IApplicationFunctions:HealthWarningDisappearedSystemEvent"); | ||
| 1345 | health_warning_disappeared_system_event->Initialize(); | ||
| 1346 | } | 1341 | } |
| 1347 | 1342 | ||
| 1348 | IApplicationFunctions::~IApplicationFunctions() = default; | 1343 | IApplicationFunctions::~IApplicationFunctions() = default; |
| @@ -1739,7 +1734,7 @@ void IApplicationFunctions::GetGpuErrorDetectedSystemEvent(Kernel::HLERequestCon | |||
| 1739 | 1734 | ||
| 1740 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 1735 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 1741 | rb.Push(RESULT_SUCCESS); | 1736 | rb.Push(RESULT_SUCCESS); |
| 1742 | rb.PushCopyObjects(gpu_error_detected_event->GetReadableEvent()); | 1737 | rb.PushCopyObjects(gpu_error_detected_event.GetReadableEvent()); |
| 1743 | } | 1738 | } |
| 1744 | 1739 | ||
| 1745 | void IApplicationFunctions::GetFriendInvitationStorageChannelEvent(Kernel::HLERequestContext& ctx) { | 1740 | void IApplicationFunctions::GetFriendInvitationStorageChannelEvent(Kernel::HLERequestContext& ctx) { |
| @@ -1747,7 +1742,7 @@ void IApplicationFunctions::GetFriendInvitationStorageChannelEvent(Kernel::HLERe | |||
| 1747 | 1742 | ||
| 1748 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 1743 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 1749 | rb.Push(RESULT_SUCCESS); | 1744 | rb.Push(RESULT_SUCCESS); |
| 1750 | rb.PushCopyObjects(friend_invitation_storage_channel_event->GetReadableEvent()); | 1745 | rb.PushCopyObjects(friend_invitation_storage_channel_event.GetReadableEvent()); |
| 1751 | } | 1746 | } |
| 1752 | 1747 | ||
| 1753 | void IApplicationFunctions::TryPopFromFriendInvitationStorageChannel( | 1748 | void IApplicationFunctions::TryPopFromFriendInvitationStorageChannel( |
| @@ -1763,7 +1758,7 @@ void IApplicationFunctions::GetHealthWarningDisappearedSystemEvent(Kernel::HLERe | |||
| 1763 | 1758 | ||
| 1764 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 1759 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 1765 | rb.Push(RESULT_SUCCESS); | 1760 | rb.Push(RESULT_SUCCESS); |
| 1766 | rb.PushCopyObjects(health_warning_disappeared_system_event->GetReadableEvent()); | 1761 | rb.PushCopyObjects(health_warning_disappeared_system_event.GetReadableEvent()); |
| 1767 | } | 1762 | } |
| 1768 | 1763 | ||
| 1769 | void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger, | 1764 | void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger, |
| @@ -1781,7 +1776,8 @@ void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger | |||
| 1781 | } | 1776 | } |
| 1782 | 1777 | ||
| 1783 | IHomeMenuFunctions::IHomeMenuFunctions(Core::System& system_) | 1778 | IHomeMenuFunctions::IHomeMenuFunctions(Core::System& system_) |
| 1784 | : ServiceFramework{system_, "IHomeMenuFunctions"} { | 1779 | : ServiceFramework{system_, "IHomeMenuFunctions"}, pop_from_general_channel_event{ |
| 1780 | system.Kernel()} { | ||
| 1785 | // clang-format off | 1781 | // clang-format off |
| 1786 | static const FunctionInfo functions[] = { | 1782 | static const FunctionInfo functions[] = { |
| 1787 | {10, &IHomeMenuFunctions::RequestToGetForeground, "RequestToGetForeground"}, | 1783 | {10, &IHomeMenuFunctions::RequestToGetForeground, "RequestToGetForeground"}, |
| @@ -1802,9 +1798,7 @@ IHomeMenuFunctions::IHomeMenuFunctions(Core::System& system_) | |||
| 1802 | 1798 | ||
| 1803 | RegisterHandlers(functions); | 1799 | RegisterHandlers(functions); |
| 1804 | 1800 | ||
| 1805 | pop_from_general_channel_event = | 1801 | pop_from_general_channel_event.Initialize("IHomeMenuFunctions:PopFromGeneralChannelEvent"); |
| 1806 | Kernel::KEvent::Create(system.Kernel(), "IHomeMenuFunctions:PopFromGeneralChannelEvent"); | ||
| 1807 | pop_from_general_channel_event->Initialize(); | ||
| 1808 | } | 1802 | } |
| 1809 | 1803 | ||
| 1810 | IHomeMenuFunctions::~IHomeMenuFunctions() = default; | 1804 | IHomeMenuFunctions::~IHomeMenuFunctions() = default; |
| @@ -1821,7 +1815,7 @@ void IHomeMenuFunctions::GetPopFromGeneralChannelEvent(Kernel::HLERequestContext | |||
| 1821 | 1815 | ||
| 1822 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 1816 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 1823 | rb.Push(RESULT_SUCCESS); | 1817 | rb.Push(RESULT_SUCCESS); |
| 1824 | rb.PushCopyObjects(pop_from_general_channel_event->GetReadableEvent()); | 1818 | rb.PushCopyObjects(pop_from_general_channel_event.GetReadableEvent()); |
| 1825 | } | 1819 | } |
| 1826 | 1820 | ||
| 1827 | IGlobalStateController::IGlobalStateController(Core::System& system_) | 1821 | IGlobalStateController::IGlobalStateController(Core::System& system_) |
diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index f8daeb437..8f6017c4e 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h | |||
| @@ -8,11 +8,11 @@ | |||
| 8 | #include <memory> | 8 | #include <memory> |
| 9 | #include <queue> | 9 | #include <queue> |
| 10 | 10 | ||
| 11 | #include "core/hle/kernel/k_event.h" | ||
| 11 | #include "core/hle/service/service.h" | 12 | #include "core/hle/service/service.h" |
| 12 | 13 | ||
| 13 | namespace Kernel { | 14 | namespace Kernel { |
| 14 | class KernelCore; | 15 | class KernelCore; |
| 15 | class KEvent; | ||
| 16 | class TransferMemory; | 16 | class TransferMemory; |
| 17 | } // namespace Kernel | 17 | } // namespace Kernel |
| 18 | 18 | ||
| @@ -67,8 +67,8 @@ public: | |||
| 67 | 67 | ||
| 68 | private: | 68 | private: |
| 69 | std::queue<AppletMessage> messages; | 69 | std::queue<AppletMessage> messages; |
| 70 | std::shared_ptr<Kernel::KEvent> on_new_message; | 70 | Kernel::KEvent on_new_message; |
| 71 | std::shared_ptr<Kernel::KEvent> on_operation_mode_changed; | 71 | Kernel::KEvent on_operation_mode_changed; |
| 72 | }; | 72 | }; |
| 73 | 73 | ||
| 74 | class IWindowController final : public ServiceFramework<IWindowController> { | 74 | class IWindowController final : public ServiceFramework<IWindowController> { |
| @@ -156,8 +156,8 @@ private: | |||
| 156 | }; | 156 | }; |
| 157 | 157 | ||
| 158 | NVFlinger::NVFlinger& nvflinger; | 158 | NVFlinger::NVFlinger& nvflinger; |
| 159 | std::shared_ptr<Kernel::KEvent> launchable_event; | 159 | Kernel::KEvent launchable_event; |
| 160 | std::shared_ptr<Kernel::KEvent> accumulated_suspended_tick_changed_event; | 160 | Kernel::KEvent accumulated_suspended_tick_changed_event; |
| 161 | 161 | ||
| 162 | u32 idle_time_detection_extension = 0; | 162 | u32 idle_time_detection_extension = 0; |
| 163 | u64 num_fatal_sections_entered = 0; | 163 | u64 num_fatal_sections_entered = 0; |
| @@ -300,9 +300,9 @@ private: | |||
| 300 | bool launch_popped_application_specific = false; | 300 | bool launch_popped_application_specific = false; |
| 301 | bool launch_popped_account_preselect = false; | 301 | bool launch_popped_account_preselect = false; |
| 302 | s32 previous_program_index{-1}; | 302 | s32 previous_program_index{-1}; |
| 303 | std::shared_ptr<Kernel::KEvent> gpu_error_detected_event; | 303 | Kernel::KEvent gpu_error_detected_event; |
| 304 | std::shared_ptr<Kernel::KEvent> friend_invitation_storage_channel_event; | 304 | Kernel::KEvent friend_invitation_storage_channel_event; |
| 305 | std::shared_ptr<Kernel::KEvent> health_warning_disappeared_system_event; | 305 | Kernel::KEvent health_warning_disappeared_system_event; |
| 306 | }; | 306 | }; |
| 307 | 307 | ||
| 308 | class IHomeMenuFunctions final : public ServiceFramework<IHomeMenuFunctions> { | 308 | class IHomeMenuFunctions final : public ServiceFramework<IHomeMenuFunctions> { |
| @@ -314,7 +314,7 @@ private: | |||
| 314 | void RequestToGetForeground(Kernel::HLERequestContext& ctx); | 314 | void RequestToGetForeground(Kernel::HLERequestContext& ctx); |
| 315 | void GetPopFromGeneralChannelEvent(Kernel::HLERequestContext& ctx); | 315 | void GetPopFromGeneralChannelEvent(Kernel::HLERequestContext& ctx); |
| 316 | 316 | ||
| 317 | std::shared_ptr<Kernel::KEvent> pop_from_general_channel_event; | 317 | Kernel::KEvent pop_from_general_channel_event; |
| 318 | }; | 318 | }; |
| 319 | 319 | ||
| 320 | class IGlobalStateController final : public ServiceFramework<IGlobalStateController> { | 320 | class IGlobalStateController final : public ServiceFramework<IGlobalStateController> { |
diff --git a/src/core/hle/service/am/applets/applets.cpp b/src/core/hle/service/am/applets/applets.cpp index c093813fe..58bff810d 100644 --- a/src/core/hle/service/am/applets/applets.cpp +++ b/src/core/hle/service/am/applets/applets.cpp | |||
| @@ -12,7 +12,6 @@ | |||
| 12 | #include "core/frontend/applets/profile_select.h" | 12 | #include "core/frontend/applets/profile_select.h" |
| 13 | #include "core/frontend/applets/software_keyboard.h" | 13 | #include "core/frontend/applets/software_keyboard.h" |
| 14 | #include "core/frontend/applets/web_browser.h" | 14 | #include "core/frontend/applets/web_browser.h" |
| 15 | #include "core/hle/kernel/k_event.h" | ||
| 16 | #include "core/hle/kernel/k_readable_event.h" | 15 | #include "core/hle/kernel/k_readable_event.h" |
| 17 | #include "core/hle/kernel/k_writable_event.h" | 16 | #include "core/hle/kernel/k_writable_event.h" |
| 18 | #include "core/hle/kernel/server_session.h" | 17 | #include "core/hle/kernel/server_session.h" |
| @@ -31,16 +30,11 @@ | |||
| 31 | namespace Service::AM::Applets { | 30 | namespace Service::AM::Applets { |
| 32 | 31 | ||
| 33 | AppletDataBroker::AppletDataBroker(Core::System& system_, LibraryAppletMode applet_mode_) | 32 | AppletDataBroker::AppletDataBroker(Core::System& system_, LibraryAppletMode applet_mode_) |
| 34 | : system{system_}, applet_mode{applet_mode_} { | 33 | : system{system_}, applet_mode{applet_mode_}, state_changed_event{system.Kernel()}, |
| 35 | state_changed_event = | 34 | pop_out_data_event{system.Kernel()}, pop_interactive_out_data_event{system.Kernel()} { |
| 36 | Kernel::KEvent::Create(system.Kernel(), "ILibraryAppletAccessor:StateChangedEvent"); | 35 | state_changed_event.Initialize("ILibraryAppletAccessor:StateChangedEvent"); |
| 37 | state_changed_event->Initialize(); | 36 | pop_out_data_event.Initialize("ILibraryAppletAccessor:PopDataOutEvent"); |
| 38 | pop_out_data_event = | 37 | pop_interactive_out_data_event.Initialize("ILibraryAppletAccessor:PopInteractiveDataOutEvent"); |
| 39 | Kernel::KEvent::Create(system.Kernel(), "ILibraryAppletAccessor:PopDataOutEvent"); | ||
| 40 | pop_out_data_event->Initialize(); | ||
| 41 | pop_interactive_out_data_event = Kernel::KEvent::Create( | ||
| 42 | system.Kernel(), "ILibraryAppletAccessor:PopInteractiveDataOutEvent"); | ||
| 43 | pop_interactive_out_data_event->Initialize(); | ||
| 44 | } | 38 | } |
| 45 | 39 | ||
| 46 | AppletDataBroker::~AppletDataBroker() = default; | 40 | AppletDataBroker::~AppletDataBroker() = default; |
| @@ -67,7 +61,7 @@ std::shared_ptr<IStorage> AppletDataBroker::PopNormalDataToGame() { | |||
| 67 | 61 | ||
| 68 | auto out = std::move(out_channel.front()); | 62 | auto out = std::move(out_channel.front()); |
| 69 | out_channel.pop_front(); | 63 | out_channel.pop_front(); |
| 70 | pop_out_data_event->GetWritableEvent()->Clear(); | 64 | pop_out_data_event.GetWritableEvent()->Clear(); |
| 71 | return out; | 65 | return out; |
| 72 | } | 66 | } |
| 73 | 67 | ||
| @@ -86,7 +80,7 @@ std::shared_ptr<IStorage> AppletDataBroker::PopInteractiveDataToGame() { | |||
| 86 | 80 | ||
| 87 | auto out = std::move(out_interactive_channel.front()); | 81 | auto out = std::move(out_interactive_channel.front()); |
| 88 | out_interactive_channel.pop_front(); | 82 | out_interactive_channel.pop_front(); |
| 89 | pop_interactive_out_data_event->GetWritableEvent()->Clear(); | 83 | pop_interactive_out_data_event.GetWritableEvent()->Clear(); |
| 90 | return out; | 84 | return out; |
| 91 | } | 85 | } |
| 92 | 86 | ||
| @@ -105,7 +99,7 @@ void AppletDataBroker::PushNormalDataFromGame(std::shared_ptr<IStorage>&& storag | |||
| 105 | 99 | ||
| 106 | void AppletDataBroker::PushNormalDataFromApplet(std::shared_ptr<IStorage>&& storage) { | 100 | void AppletDataBroker::PushNormalDataFromApplet(std::shared_ptr<IStorage>&& storage) { |
| 107 | out_channel.emplace_back(std::move(storage)); | 101 | out_channel.emplace_back(std::move(storage)); |
| 108 | pop_out_data_event->GetWritableEvent()->Signal(); | 102 | pop_out_data_event.GetWritableEvent()->Signal(); |
| 109 | } | 103 | } |
| 110 | 104 | ||
| 111 | void AppletDataBroker::PushInteractiveDataFromGame(std::shared_ptr<IStorage>&& storage) { | 105 | void AppletDataBroker::PushInteractiveDataFromGame(std::shared_ptr<IStorage>&& storage) { |
| @@ -114,11 +108,11 @@ void AppletDataBroker::PushInteractiveDataFromGame(std::shared_ptr<IStorage>&& s | |||
| 114 | 108 | ||
| 115 | void AppletDataBroker::PushInteractiveDataFromApplet(std::shared_ptr<IStorage>&& storage) { | 109 | void AppletDataBroker::PushInteractiveDataFromApplet(std::shared_ptr<IStorage>&& storage) { |
| 116 | out_interactive_channel.emplace_back(std::move(storage)); | 110 | out_interactive_channel.emplace_back(std::move(storage)); |
| 117 | pop_interactive_out_data_event->GetWritableEvent()->Signal(); | 111 | pop_interactive_out_data_event.GetWritableEvent()->Signal(); |
| 118 | } | 112 | } |
| 119 | 113 | ||
| 120 | void AppletDataBroker::SignalStateChanged() const { | 114 | void AppletDataBroker::SignalStateChanged() { |
| 121 | state_changed_event->GetWritableEvent()->Signal(); | 115 | state_changed_event.GetWritableEvent()->Signal(); |
| 122 | 116 | ||
| 123 | switch (applet_mode) { | 117 | switch (applet_mode) { |
| 124 | case LibraryAppletMode::AllForeground: | 118 | case LibraryAppletMode::AllForeground: |
| @@ -143,15 +137,15 @@ void AppletDataBroker::SignalStateChanged() const { | |||
| 143 | } | 137 | } |
| 144 | 138 | ||
| 145 | Kernel::KReadableEvent* AppletDataBroker::GetNormalDataEvent() const { | 139 | Kernel::KReadableEvent* AppletDataBroker::GetNormalDataEvent() const { |
| 146 | return pop_out_data_event->GetReadableEvent(); | 140 | return pop_out_data_event.GetReadableEvent().get(); |
| 147 | } | 141 | } |
| 148 | 142 | ||
| 149 | Kernel::KReadableEvent* AppletDataBroker::GetInteractiveDataEvent() const { | 143 | Kernel::KReadableEvent* AppletDataBroker::GetInteractiveDataEvent() const { |
| 150 | return pop_interactive_out_data_event->GetReadableEvent(); | 144 | return pop_interactive_out_data_event.GetReadableEvent().get(); |
| 151 | } | 145 | } |
| 152 | 146 | ||
| 153 | Kernel::KReadableEvent* AppletDataBroker::GetStateChangedEvent() const { | 147 | Kernel::KReadableEvent* AppletDataBroker::GetStateChangedEvent() const { |
| 154 | return state_changed_event->GetReadableEvent(); | 148 | return state_changed_event.GetReadableEvent().get(); |
| 155 | } | 149 | } |
| 156 | 150 | ||
| 157 | Applet::Applet(Core::System& system_, LibraryAppletMode applet_mode_) | 151 | Applet::Applet(Core::System& system_, LibraryAppletMode applet_mode_) |
diff --git a/src/core/hle/service/am/applets/applets.h b/src/core/hle/service/am/applets/applets.h index ffde8ced0..327843a98 100644 --- a/src/core/hle/service/am/applets/applets.h +++ b/src/core/hle/service/am/applets/applets.h | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include <queue> | 8 | #include <queue> |
| 9 | 9 | ||
| 10 | #include "common/swap.h" | 10 | #include "common/swap.h" |
| 11 | #include "core/hle/kernel/k_event.h" | ||
| 11 | #include "core/hle/kernel/object.h" | 12 | #include "core/hle/kernel/object.h" |
| 12 | 13 | ||
| 13 | union ResultCode; | 14 | union ResultCode; |
| @@ -119,13 +120,13 @@ private: | |||
| 119 | // PopInteractiveDataToGame and PushInteractiveDataFromApplet | 120 | // PopInteractiveDataToGame and PushInteractiveDataFromApplet |
| 120 | std::deque<std::shared_ptr<IStorage>> out_interactive_channel; | 121 | std::deque<std::shared_ptr<IStorage>> out_interactive_channel; |
| 121 | 122 | ||
| 122 | std::shared_ptr<Kernel::KEvent> state_changed_event; | 123 | Kernel::KEvent state_changed_event; |
| 123 | 124 | ||
| 124 | // Signaled on PushNormalDataFromApplet | 125 | // Signaled on PushNormalDataFromApplet |
| 125 | std::shared_ptr<Kernel::KEvent> pop_out_data_event; | 126 | Kernel::KEvent pop_out_data_event; |
| 126 | 127 | ||
| 127 | // Signaled on PushInteractiveDataFromApplet | 128 | // Signaled on PushInteractiveDataFromApplet |
| 128 | std::shared_ptr<Kernel::KEvent> pop_interactive_out_data_event; | 129 | Kernel::KEvent pop_interactive_out_data_event; |
| 129 | }; | 130 | }; |
| 130 | 131 | ||
| 131 | class Applet { | 132 | class Applet { |
diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp index 75867e349..12a025610 100644 --- a/src/core/hle/service/aoc/aoc_u.cpp +++ b/src/core/hle/service/aoc/aoc_u.cpp | |||
| @@ -16,7 +16,6 @@ | |||
| 16 | #include "core/file_sys/patch_manager.h" | 16 | #include "core/file_sys/patch_manager.h" |
| 17 | #include "core/file_sys/registered_cache.h" | 17 | #include "core/file_sys/registered_cache.h" |
| 18 | #include "core/hle/ipc_helpers.h" | 18 | #include "core/hle/ipc_helpers.h" |
| 19 | #include "core/hle/kernel/k_event.h" | ||
| 20 | #include "core/hle/kernel/k_readable_event.h" | 19 | #include "core/hle/kernel/k_readable_event.h" |
| 21 | #include "core/hle/kernel/kernel.h" | 20 | #include "core/hle/kernel/kernel.h" |
| 22 | #include "core/hle/kernel/process.h" | 21 | #include "core/hle/kernel/process.h" |
| @@ -50,7 +49,7 @@ static std::vector<u64> AccumulateAOCTitleIDs(Core::System& system) { | |||
| 50 | class IPurchaseEventManager final : public ServiceFramework<IPurchaseEventManager> { | 49 | class IPurchaseEventManager final : public ServiceFramework<IPurchaseEventManager> { |
| 51 | public: | 50 | public: |
| 52 | explicit IPurchaseEventManager(Core::System& system_) | 51 | explicit IPurchaseEventManager(Core::System& system_) |
| 53 | : ServiceFramework{system_, "IPurchaseEventManager"} { | 52 | : ServiceFramework{system_, "IPurchaseEventManager"}, purchased_event{system.Kernel()} { |
| 54 | // clang-format off | 53 | // clang-format off |
| 55 | static const FunctionInfo functions[] = { | 54 | static const FunctionInfo functions[] = { |
| 56 | {0, &IPurchaseEventManager::SetDefaultDeliveryTarget, "SetDefaultDeliveryTarget"}, | 55 | {0, &IPurchaseEventManager::SetDefaultDeliveryTarget, "SetDefaultDeliveryTarget"}, |
| @@ -63,9 +62,7 @@ public: | |||
| 63 | 62 | ||
| 64 | RegisterHandlers(functions); | 63 | RegisterHandlers(functions); |
| 65 | 64 | ||
| 66 | purchased_event = | 65 | purchased_event.Initialize("IPurchaseEventManager:PurchasedEvent"); |
| 67 | Kernel::KEvent::Create(system.Kernel(), "IPurchaseEventManager:PurchasedEvent"); | ||
| 68 | purchased_event->Initialize(); | ||
| 69 | } | 66 | } |
| 70 | 67 | ||
| 71 | private: | 68 | private: |
| @@ -98,14 +95,15 @@ private: | |||
| 98 | 95 | ||
| 99 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 96 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 100 | rb.Push(RESULT_SUCCESS); | 97 | rb.Push(RESULT_SUCCESS); |
| 101 | rb.PushCopyObjects(purchased_event->GetReadableEvent()); | 98 | rb.PushCopyObjects(purchased_event.GetReadableEvent()); |
| 102 | } | 99 | } |
| 103 | 100 | ||
| 104 | std::shared_ptr<Kernel::KEvent> purchased_event; | 101 | Kernel::KEvent purchased_event; |
| 105 | }; | 102 | }; |
| 106 | 103 | ||
| 107 | AOC_U::AOC_U(Core::System& system_) | 104 | AOC_U::AOC_U(Core::System& system_) |
| 108 | : ServiceFramework{system_, "aoc:u"}, add_on_content{AccumulateAOCTitleIDs(system)} { | 105 | : ServiceFramework{system_, "aoc:u"}, add_on_content{AccumulateAOCTitleIDs(system)}, |
| 106 | aoc_change_event{system.Kernel()} { | ||
| 109 | // clang-format off | 107 | // clang-format off |
| 110 | static const FunctionInfo functions[] = { | 108 | static const FunctionInfo functions[] = { |
| 111 | {0, nullptr, "CountAddOnContentByApplicationId"}, | 109 | {0, nullptr, "CountAddOnContentByApplicationId"}, |
| @@ -127,9 +125,7 @@ AOC_U::AOC_U(Core::System& system_) | |||
| 127 | 125 | ||
| 128 | RegisterHandlers(functions); | 126 | RegisterHandlers(functions); |
| 129 | 127 | ||
| 130 | auto& kernel = system.Kernel(); | 128 | aoc_change_event.Initialize("GetAddOnContentListChanged:Event"); |
| 131 | aoc_change_event = Kernel::KEvent::Create(kernel, "GetAddOnContentListChanged:Event"); | ||
| 132 | aoc_change_event->Initialize(); | ||
| 133 | } | 129 | } |
| 134 | 130 | ||
| 135 | AOC_U::~AOC_U() = default; | 131 | AOC_U::~AOC_U() = default; |
| @@ -256,7 +252,7 @@ void AOC_U::GetAddOnContentListChangedEvent(Kernel::HLERequestContext& ctx) { | |||
| 256 | 252 | ||
| 257 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 253 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 258 | rb.Push(RESULT_SUCCESS); | 254 | rb.Push(RESULT_SUCCESS); |
| 259 | rb.PushCopyObjects(aoc_change_event->GetReadableEvent()); | 255 | rb.PushCopyObjects(aoc_change_event.GetReadableEvent()); |
| 260 | } | 256 | } |
| 261 | 257 | ||
| 262 | void AOC_U::CreateEcPurchasedEventManager(Kernel::HLERequestContext& ctx) { | 258 | 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 1aa23529e..65095baa2 100644 --- a/src/core/hle/service/aoc/aoc_u.h +++ b/src/core/hle/service/aoc/aoc_u.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include "core/hle/kernel/k_event.h" | ||
| 7 | #include "core/hle/service/service.h" | 8 | #include "core/hle/service/service.h" |
| 8 | 9 | ||
| 9 | namespace Core { | 10 | namespace Core { |
| @@ -31,7 +32,7 @@ private: | |||
| 31 | void CreatePermanentEcPurchasedEventManager(Kernel::HLERequestContext& ctx); | 32 | void CreatePermanentEcPurchasedEventManager(Kernel::HLERequestContext& ctx); |
| 32 | 33 | ||
| 33 | std::vector<u64> add_on_content; | 34 | std::vector<u64> add_on_content; |
| 34 | std::shared_ptr<Kernel::KEvent> aoc_change_event; | 35 | Kernel::KEvent aoc_change_event; |
| 35 | }; | 36 | }; |
| 36 | 37 | ||
| 37 | /// Registers all AOC services with the specified service manager. | 38 | /// 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 5f51fca9a..4052c8e60 100644 --- a/src/core/hle/service/audio/audout_u.cpp +++ b/src/core/hle/service/audio/audout_u.cpp | |||
| @@ -43,9 +43,9 @@ class IAudioOut final : public ServiceFramework<IAudioOut> { | |||
| 43 | public: | 43 | public: |
| 44 | IAudioOut(Core::System& system_, AudoutParams audio_params_, AudioCore::AudioOut& audio_core_, | 44 | IAudioOut(Core::System& system_, AudoutParams audio_params_, AudioCore::AudioOut& audio_core_, |
| 45 | std::string&& device_name_, std::string&& unique_name) | 45 | std::string&& device_name_, std::string&& unique_name) |
| 46 | : ServiceFramework{system_, "IAudioOut"}, audio_core{audio_core_}, | 46 | : ServiceFramework{system_, "IAudioOut"}, audio_core{audio_core_}, device_name{std::move( |
| 47 | device_name{std::move(device_name_)}, audio_params{audio_params_}, main_memory{ | 47 | device_name_)}, |
| 48 | system.Memory()} { | 48 | audio_params{audio_params_}, buffer_event{system.Kernel()}, main_memory{system.Memory()} { |
| 49 | // clang-format off | 49 | // clang-format off |
| 50 | static const FunctionInfo functions[] = { | 50 | static const FunctionInfo functions[] = { |
| 51 | {0, &IAudioOut::GetAudioOutState, "GetAudioOutState"}, | 51 | {0, &IAudioOut::GetAudioOutState, "GetAudioOutState"}, |
| @@ -67,13 +67,12 @@ public: | |||
| 67 | RegisterHandlers(functions); | 67 | RegisterHandlers(functions); |
| 68 | 68 | ||
| 69 | // This is the event handle used to check if the audio buffer was released | 69 | // This is the event handle used to check if the audio buffer was released |
| 70 | buffer_event = Kernel::KEvent::Create(system.Kernel(), "IAudioOutBufferReleased"); | 70 | buffer_event.Initialize("IAudioOutBufferReleased"); |
| 71 | buffer_event->Initialize(); | ||
| 72 | 71 | ||
| 73 | stream = audio_core.OpenStream(system.CoreTiming(), audio_params.sample_rate, | 72 | stream = audio_core.OpenStream(system.CoreTiming(), audio_params.sample_rate, |
| 74 | audio_params.channel_count, std::move(unique_name), [this] { | 73 | audio_params.channel_count, std::move(unique_name), [this] { |
| 75 | const auto guard = LockService(); | 74 | const auto guard = LockService(); |
| 76 | buffer_event->GetWritableEvent()->Signal(); | 75 | buffer_event.GetWritableEvent()->Signal(); |
| 77 | }); | 76 | }); |
| 78 | } | 77 | } |
| 79 | 78 | ||
| @@ -126,7 +125,7 @@ private: | |||
| 126 | 125 | ||
| 127 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 126 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 128 | rb.Push(RESULT_SUCCESS); | 127 | rb.Push(RESULT_SUCCESS); |
| 129 | rb.PushCopyObjects(buffer_event->GetReadableEvent()); | 128 | rb.PushCopyObjects(buffer_event.GetReadableEvent()); |
| 130 | } | 129 | } |
| 131 | 130 | ||
| 132 | void AppendAudioOutBufferImpl(Kernel::HLERequestContext& ctx) { | 131 | void AppendAudioOutBufferImpl(Kernel::HLERequestContext& ctx) { |
| @@ -220,7 +219,7 @@ private: | |||
| 220 | [[maybe_unused]] AudoutParams audio_params{}; | 219 | [[maybe_unused]] AudoutParams audio_params{}; |
| 221 | 220 | ||
| 222 | /// This is the event handle used to check if the audio buffer was released | 221 | /// This is the event handle used to check if the audio buffer was released |
| 223 | std::shared_ptr<Kernel::KEvent> buffer_event; | 222 | Kernel::KEvent buffer_event; |
| 224 | Core::Memory::Memory& main_memory; | 223 | Core::Memory::Memory& main_memory; |
| 225 | }; | 224 | }; |
| 226 | 225 | ||
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index 3a48342fd..d573530df 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp | |||
| @@ -30,7 +30,7 @@ public: | |||
| 30 | explicit IAudioRenderer(Core::System& system_, | 30 | explicit IAudioRenderer(Core::System& system_, |
| 31 | const AudioCommon::AudioRendererParameter& audren_params, | 31 | const AudioCommon::AudioRendererParameter& audren_params, |
| 32 | const std::size_t instance_number) | 32 | const std::size_t instance_number) |
| 33 | : ServiceFramework{system_, "IAudioRenderer"} { | 33 | : ServiceFramework{system_, "IAudioRenderer"}, system_event{system.Kernel()} { |
| 34 | // clang-format off | 34 | // clang-format off |
| 35 | static const FunctionInfo functions[] = { | 35 | static const FunctionInfo functions[] = { |
| 36 | {0, &IAudioRenderer::GetSampleRate, "GetSampleRate"}, | 36 | {0, &IAudioRenderer::GetSampleRate, "GetSampleRate"}, |
| @@ -49,13 +49,12 @@ public: | |||
| 49 | // clang-format on | 49 | // clang-format on |
| 50 | RegisterHandlers(functions); | 50 | RegisterHandlers(functions); |
| 51 | 51 | ||
| 52 | system_event = Kernel::KEvent::Create(system.Kernel(), "IAudioRenderer:SystemEvent"); | 52 | system_event.Initialize("IAudioRenderer:SystemEvent"); |
| 53 | system_event->Initialize(); | ||
| 54 | renderer = std::make_unique<AudioCore::AudioRenderer>( | 53 | renderer = std::make_unique<AudioCore::AudioRenderer>( |
| 55 | system.CoreTiming(), system.Memory(), audren_params, | 54 | system.CoreTiming(), system.Memory(), audren_params, |
| 56 | [this]() { | 55 | [this]() { |
| 57 | const auto guard = LockService(); | 56 | const auto guard = LockService(); |
| 58 | system_event->GetWritableEvent()->Signal(); | 57 | system_event.GetWritableEvent()->Signal(); |
| 59 | }, | 58 | }, |
| 60 | instance_number); | 59 | instance_number); |
| 61 | } | 60 | } |
| @@ -128,7 +127,7 @@ private: | |||
| 128 | 127 | ||
| 129 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 128 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 130 | rb.Push(RESULT_SUCCESS); | 129 | rb.Push(RESULT_SUCCESS); |
| 131 | rb.PushCopyObjects(system_event->GetReadableEvent()); | 130 | rb.PushCopyObjects(system_event.GetReadableEvent()); |
| 132 | } | 131 | } |
| 133 | 132 | ||
| 134 | void SetRenderingTimeLimit(Kernel::HLERequestContext& ctx) { | 133 | void SetRenderingTimeLimit(Kernel::HLERequestContext& ctx) { |
| @@ -162,7 +161,7 @@ private: | |||
| 162 | rb.Push(ERR_NOT_SUPPORTED); | 161 | rb.Push(ERR_NOT_SUPPORTED); |
| 163 | } | 162 | } |
| 164 | 163 | ||
| 165 | std::shared_ptr<Kernel::KEvent> system_event; | 164 | Kernel::KEvent system_event; |
| 166 | std::unique_ptr<AudioCore::AudioRenderer> renderer; | 165 | std::unique_ptr<AudioCore::AudioRenderer> renderer; |
| 167 | u32 rendering_time_limit_percent = 100; | 166 | u32 rendering_time_limit_percent = 100; |
| 168 | }; | 167 | }; |
| @@ -170,7 +169,9 @@ private: | |||
| 170 | class IAudioDevice final : public ServiceFramework<IAudioDevice> { | 169 | class IAudioDevice final : public ServiceFramework<IAudioDevice> { |
| 171 | public: | 170 | public: |
| 172 | explicit IAudioDevice(Core::System& system_, u32_le revision_num) | 171 | explicit IAudioDevice(Core::System& system_, u32_le revision_num) |
| 173 | : ServiceFramework{system_, "IAudioDevice"}, revision{revision_num} { | 172 | : ServiceFramework{system_, "IAudioDevice"}, revision{revision_num}, |
| 173 | buffer_event{system.Kernel()}, audio_input_device_switch_event{system.Kernel()}, | ||
| 174 | audio_output_device_switch_event{system.Kernel()} { | ||
| 174 | static const FunctionInfo functions[] = { | 175 | static const FunctionInfo functions[] = { |
| 175 | {0, &IAudioDevice::ListAudioDeviceName, "ListAudioDeviceName"}, | 176 | {0, &IAudioDevice::ListAudioDeviceName, "ListAudioDeviceName"}, |
| 176 | {1, &IAudioDevice::SetAudioDeviceOutputVolume, "SetAudioDeviceOutputVolume"}, | 177 | {1, &IAudioDevice::SetAudioDeviceOutputVolume, "SetAudioDeviceOutputVolume"}, |
| @@ -188,20 +189,14 @@ public: | |||
| 188 | }; | 189 | }; |
| 189 | RegisterHandlers(functions); | 190 | RegisterHandlers(functions); |
| 190 | 191 | ||
| 191 | auto& kernel = system.Kernel(); | 192 | buffer_event.Initialize("IAudioOutBufferReleasedEvent"); |
| 192 | buffer_event = Kernel::KEvent::Create(kernel, "IAudioOutBufferReleasedEvent"); | ||
| 193 | buffer_event->Initialize(); | ||
| 194 | 193 | ||
| 195 | // Should be similar to audio_output_device_switch_event | 194 | // Should be similar to audio_output_device_switch_event |
| 196 | audio_input_device_switch_event = | 195 | audio_input_device_switch_event.Initialize("IAudioDevice:AudioInputDeviceSwitchedEvent"); |
| 197 | Kernel::KEvent::Create(kernel, "IAudioDevice:AudioInputDeviceSwitchedEvent"); | ||
| 198 | audio_input_device_switch_event->Initialize(); | ||
| 199 | 196 | ||
| 200 | // Should only be signalled when an audio output device has been changed, example: speaker | 197 | // Should only be signalled when an audio output device has been changed, example: speaker |
| 201 | // to headset | 198 | // to headset |
| 202 | audio_output_device_switch_event = | 199 | audio_output_device_switch_event.Initialize("IAudioDevice:AudioOutputDeviceSwitchedEvent"); |
| 203 | Kernel::KEvent::Create(kernel, "IAudioDevice:AudioOutputDeviceSwitchedEvent"); | ||
| 204 | audio_output_device_switch_event->Initialize(); | ||
| 205 | } | 200 | } |
| 206 | 201 | ||
| 207 | private: | 202 | private: |
| @@ -290,11 +285,11 @@ private: | |||
| 290 | void QueryAudioDeviceSystemEvent(Kernel::HLERequestContext& ctx) { | 285 | void QueryAudioDeviceSystemEvent(Kernel::HLERequestContext& ctx) { |
| 291 | LOG_WARNING(Service_Audio, "(STUBBED) called"); | 286 | LOG_WARNING(Service_Audio, "(STUBBED) called"); |
| 292 | 287 | ||
| 293 | buffer_event->GetWritableEvent()->Signal(); | 288 | buffer_event.GetWritableEvent()->Signal(); |
| 294 | 289 | ||
| 295 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 290 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 296 | rb.Push(RESULT_SUCCESS); | 291 | rb.Push(RESULT_SUCCESS); |
| 297 | rb.PushCopyObjects(buffer_event->GetReadableEvent()); | 292 | rb.PushCopyObjects(buffer_event.GetReadableEvent()); |
| 298 | } | 293 | } |
| 299 | 294 | ||
| 300 | void GetActiveChannelCount(Kernel::HLERequestContext& ctx) { | 295 | void GetActiveChannelCount(Kernel::HLERequestContext& ctx) { |
| @@ -311,7 +306,7 @@ private: | |||
| 311 | 306 | ||
| 312 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 307 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 313 | rb.Push(RESULT_SUCCESS); | 308 | rb.Push(RESULT_SUCCESS); |
| 314 | rb.PushCopyObjects(audio_input_device_switch_event->GetReadableEvent()); | 309 | rb.PushCopyObjects(audio_input_device_switch_event.GetReadableEvent()); |
| 315 | } | 310 | } |
| 316 | 311 | ||
| 317 | void QueryAudioDeviceOutputEvent(Kernel::HLERequestContext& ctx) { | 312 | void QueryAudioDeviceOutputEvent(Kernel::HLERequestContext& ctx) { |
| @@ -319,13 +314,13 @@ private: | |||
| 319 | 314 | ||
| 320 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 315 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 321 | rb.Push(RESULT_SUCCESS); | 316 | rb.Push(RESULT_SUCCESS); |
| 322 | rb.PushCopyObjects(audio_output_device_switch_event->GetReadableEvent()); | 317 | rb.PushCopyObjects(audio_output_device_switch_event.GetReadableEvent()); |
| 323 | } | 318 | } |
| 324 | 319 | ||
| 325 | u32_le revision = 0; | 320 | u32_le revision = 0; |
| 326 | std::shared_ptr<Kernel::KEvent> buffer_event; | 321 | Kernel::KEvent buffer_event; |
| 327 | std::shared_ptr<Kernel::KEvent> audio_input_device_switch_event; | 322 | Kernel::KEvent audio_input_device_switch_event; |
| 328 | std::shared_ptr<Kernel::KEvent> audio_output_device_switch_event; | 323 | Kernel::KEvent audio_output_device_switch_event; |
| 329 | 324 | ||
| 330 | }; // namespace Audio | 325 | }; // namespace Audio |
| 331 | 326 | ||
diff --git a/src/core/hle/service/bcat/backend/backend.cpp b/src/core/hle/service/bcat/backend/backend.cpp index 7f301fdeb..932e70bfd 100644 --- a/src/core/hle/service/bcat/backend/backend.cpp +++ b/src/core/hle/service/bcat/backend/backend.cpp | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | #include "common/hex_util.h" | 5 | #include "common/hex_util.h" |
| 6 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 7 | #include "core/core.h" | 7 | #include "core/core.h" |
| 8 | #include "core/hle/kernel/k_event.h" | ||
| 9 | #include "core/hle/kernel/k_readable_event.h" | 8 | #include "core/hle/kernel/k_readable_event.h" |
| 10 | #include "core/hle/kernel/k_writable_event.h" | 9 | #include "core/hle/kernel/k_writable_event.h" |
| 11 | #include "core/hle/lock.h" | 10 | #include "core/hle/lock.h" |
| @@ -14,14 +13,13 @@ | |||
| 14 | namespace Service::BCAT { | 13 | namespace Service::BCAT { |
| 15 | 14 | ||
| 16 | ProgressServiceBackend::ProgressServiceBackend(Kernel::KernelCore& kernel, | 15 | ProgressServiceBackend::ProgressServiceBackend(Kernel::KernelCore& kernel, |
| 17 | std::string_view event_name) { | 16 | std::string_view event_name) |
| 18 | event = Kernel::KEvent::Create(kernel, | 17 | : update_event{kernel} { |
| 19 | "ProgressServiceBackend:UpdateEvent:" + std::string(event_name)); | 18 | update_event.Initialize("ProgressServiceBackend:UpdateEvent:" + std::string(event_name)); |
| 20 | event->Initialize(); | ||
| 21 | } | 19 | } |
| 22 | 20 | ||
| 23 | std::shared_ptr<Kernel::KReadableEvent> ProgressServiceBackend::GetEvent() const { | 21 | std::shared_ptr<Kernel::KReadableEvent> ProgressServiceBackend::GetEvent() const { |
| 24 | return SharedFrom(event->GetReadableEvent()); | 22 | return update_event.GetReadableEvent(); |
| 25 | } | 23 | } |
| 26 | 24 | ||
| 27 | DeliveryCacheProgressImpl& ProgressServiceBackend::GetImpl() { | 25 | DeliveryCacheProgressImpl& ProgressServiceBackend::GetImpl() { |
| @@ -89,9 +87,9 @@ void ProgressServiceBackend::FinishDownload(ResultCode result) { | |||
| 89 | void ProgressServiceBackend::SignalUpdate() const { | 87 | void ProgressServiceBackend::SignalUpdate() const { |
| 90 | if (need_hle_lock) { | 88 | if (need_hle_lock) { |
| 91 | std::lock_guard lock(HLE::g_hle_lock); | 89 | std::lock_guard lock(HLE::g_hle_lock); |
| 92 | event->GetWritableEvent()->Signal(); | 90 | update_event.GetWritableEvent()->Signal(); |
| 93 | } else { | 91 | } else { |
| 94 | event->GetWritableEvent()->Signal(); | 92 | update_event.GetWritableEvent()->Signal(); |
| 95 | } | 93 | } |
| 96 | } | 94 | } |
| 97 | 95 | ||
diff --git a/src/core/hle/service/bcat/backend/backend.h b/src/core/hle/service/bcat/backend/backend.h index db585b069..baa4d576a 100644 --- a/src/core/hle/service/bcat/backend/backend.h +++ b/src/core/hle/service/bcat/backend/backend.h | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 13 | #include "core/file_sys/vfs_types.h" | 13 | #include "core/file_sys/vfs_types.h" |
| 14 | #include "core/hle/kernel/k_event.h" | ||
| 14 | #include "core/hle/result.h" | 15 | #include "core/hle/result.h" |
| 15 | 16 | ||
| 16 | namespace Core { | 17 | namespace Core { |
| @@ -104,7 +105,7 @@ private: | |||
| 104 | void SignalUpdate() const; | 105 | void SignalUpdate() const; |
| 105 | 106 | ||
| 106 | DeliveryCacheProgressImpl impl{}; | 107 | DeliveryCacheProgressImpl impl{}; |
| 107 | std::shared_ptr<Kernel::KEvent> event; | 108 | Kernel::KEvent update_event; |
| 108 | bool need_hle_lock = false; | 109 | bool need_hle_lock = false; |
| 109 | }; | 110 | }; |
| 110 | 111 | ||
diff --git a/src/core/hle/service/btdrv/btdrv.cpp b/src/core/hle/service/btdrv/btdrv.cpp index af3a5842d..dde276ff4 100644 --- a/src/core/hle/service/btdrv/btdrv.cpp +++ b/src/core/hle/service/btdrv/btdrv.cpp | |||
| @@ -17,7 +17,8 @@ namespace Service::BtDrv { | |||
| 17 | 17 | ||
| 18 | class Bt final : public ServiceFramework<Bt> { | 18 | class Bt final : public ServiceFramework<Bt> { |
| 19 | public: | 19 | public: |
| 20 | explicit Bt(Core::System& system_) : ServiceFramework{system_, "bt"} { | 20 | explicit Bt(Core::System& system_) |
| 21 | : ServiceFramework{system_, "bt"}, register_event{system.Kernel()} { | ||
| 21 | // clang-format off | 22 | // clang-format off |
| 22 | static const FunctionInfo functions[] = { | 23 | static const FunctionInfo functions[] = { |
| 23 | {0, nullptr, "LeClientReadCharacteristic"}, | 24 | {0, nullptr, "LeClientReadCharacteristic"}, |
| @@ -34,9 +35,7 @@ public: | |||
| 34 | // clang-format on | 35 | // clang-format on |
| 35 | RegisterHandlers(functions); | 36 | RegisterHandlers(functions); |
| 36 | 37 | ||
| 37 | auto& kernel = system.Kernel(); | 38 | register_event.Initialize("BT:RegisterEvent"); |
| 38 | register_event = Kernel::KEvent::Create(kernel, "BT:RegisterEvent"); | ||
| 39 | register_event->Initialize(); | ||
| 40 | } | 39 | } |
| 41 | 40 | ||
| 42 | private: | 41 | private: |
| @@ -45,10 +44,10 @@ private: | |||
| 45 | 44 | ||
| 46 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 45 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 47 | rb.Push(RESULT_SUCCESS); | 46 | rb.Push(RESULT_SUCCESS); |
| 48 | rb.PushCopyObjects(register_event->GetReadableEvent()); | 47 | rb.PushCopyObjects(register_event.GetReadableEvent()); |
| 49 | } | 48 | } |
| 50 | 49 | ||
| 51 | std::shared_ptr<Kernel::KEvent> register_event; | 50 | Kernel::KEvent register_event; |
| 52 | }; | 51 | }; |
| 53 | 52 | ||
| 54 | class BtDrv final : public ServiceFramework<BtDrv> { | 53 | class BtDrv final : public ServiceFramework<BtDrv> { |
diff --git a/src/core/hle/service/btm/btm.cpp b/src/core/hle/service/btm/btm.cpp index d1ebc2388..403296650 100644 --- a/src/core/hle/service/btm/btm.cpp +++ b/src/core/hle/service/btm/btm.cpp | |||
| @@ -18,7 +18,10 @@ namespace Service::BTM { | |||
| 18 | 18 | ||
| 19 | class IBtmUserCore final : public ServiceFramework<IBtmUserCore> { | 19 | class IBtmUserCore final : public ServiceFramework<IBtmUserCore> { |
| 20 | public: | 20 | public: |
| 21 | explicit IBtmUserCore(Core::System& system_) : ServiceFramework{system_, "IBtmUserCore"} { | 21 | explicit IBtmUserCore(Core::System& system_) |
| 22 | : ServiceFramework{system_, "IBtmUserCore"}, scan_event{system.Kernel()}, | ||
| 23 | connection_event{system.Kernel()}, service_discovery{system.Kernel()}, | ||
| 24 | config_event{system.Kernel()} { | ||
| 22 | // clang-format off | 25 | // clang-format off |
| 23 | static const FunctionInfo functions[] = { | 26 | static const FunctionInfo functions[] = { |
| 24 | {0, &IBtmUserCore::AcquireBleScanEvent, "AcquireBleScanEvent"}, | 27 | {0, &IBtmUserCore::AcquireBleScanEvent, "AcquireBleScanEvent"}, |
| @@ -57,15 +60,10 @@ public: | |||
| 57 | // clang-format on | 60 | // clang-format on |
| 58 | RegisterHandlers(functions); | 61 | RegisterHandlers(functions); |
| 59 | 62 | ||
| 60 | auto& kernel = system.Kernel(); | 63 | scan_event.Initialize("IBtmUserCore:ScanEvent"); |
| 61 | scan_event = Kernel::KEvent::Create(kernel, "IBtmUserCore:ScanEvent"); | 64 | connection_event.Initialize("IBtmUserCore:ConnectionEvent"); |
| 62 | scan_event->Initialize(); | 65 | service_discovery.Initialize("IBtmUserCore:Discovery"); |
| 63 | connection_event = Kernel::KEvent::Create(kernel, "IBtmUserCore:ConnectionEvent"); | 66 | config_event.Initialize("IBtmUserCore:ConfigEvent"); |
| 64 | connection_event->Initialize(); | ||
| 65 | service_discovery = Kernel::KEvent::Create(kernel, "IBtmUserCore:Discovery"); | ||
| 66 | service_discovery->Initialize(); | ||
| 67 | config_event = Kernel::KEvent::Create(kernel, "IBtmUserCore:ConfigEvent"); | ||
| 68 | config_event->Initialize(); | ||
| 69 | } | 67 | } |
| 70 | 68 | ||
| 71 | private: | 69 | private: |
| @@ -74,7 +72,7 @@ private: | |||
| 74 | 72 | ||
| 75 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 73 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 76 | rb.Push(RESULT_SUCCESS); | 74 | rb.Push(RESULT_SUCCESS); |
| 77 | rb.PushCopyObjects(scan_event->GetReadableEvent()); | 75 | rb.PushCopyObjects(scan_event.GetReadableEvent()); |
| 78 | } | 76 | } |
| 79 | 77 | ||
| 80 | void AcquireBleConnectionEvent(Kernel::HLERequestContext& ctx) { | 78 | void AcquireBleConnectionEvent(Kernel::HLERequestContext& ctx) { |
| @@ -82,7 +80,7 @@ private: | |||
| 82 | 80 | ||
| 83 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 81 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 84 | rb.Push(RESULT_SUCCESS); | 82 | rb.Push(RESULT_SUCCESS); |
| 85 | rb.PushCopyObjects(connection_event->GetReadableEvent()); | 83 | rb.PushCopyObjects(connection_event.GetReadableEvent()); |
| 86 | } | 84 | } |
| 87 | 85 | ||
| 88 | void AcquireBleServiceDiscoveryEvent(Kernel::HLERequestContext& ctx) { | 86 | void AcquireBleServiceDiscoveryEvent(Kernel::HLERequestContext& ctx) { |
| @@ -90,7 +88,7 @@ private: | |||
| 90 | 88 | ||
| 91 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 89 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 92 | rb.Push(RESULT_SUCCESS); | 90 | rb.Push(RESULT_SUCCESS); |
| 93 | rb.PushCopyObjects(service_discovery->GetReadableEvent()); | 91 | rb.PushCopyObjects(service_discovery.GetReadableEvent()); |
| 94 | } | 92 | } |
| 95 | 93 | ||
| 96 | void AcquireBleMtuConfigEvent(Kernel::HLERequestContext& ctx) { | 94 | void AcquireBleMtuConfigEvent(Kernel::HLERequestContext& ctx) { |
| @@ -98,13 +96,13 @@ private: | |||
| 98 | 96 | ||
| 99 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 97 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 100 | rb.Push(RESULT_SUCCESS); | 98 | rb.Push(RESULT_SUCCESS); |
| 101 | rb.PushCopyObjects(config_event->GetReadableEvent()); | 99 | rb.PushCopyObjects(config_event.GetReadableEvent()); |
| 102 | } | 100 | } |
| 103 | 101 | ||
| 104 | std::shared_ptr<Kernel::KEvent> scan_event; | 102 | Kernel::KEvent scan_event; |
| 105 | std::shared_ptr<Kernel::KEvent> connection_event; | 103 | Kernel::KEvent connection_event; |
| 106 | std::shared_ptr<Kernel::KEvent> service_discovery; | 104 | Kernel::KEvent service_discovery; |
| 107 | std::shared_ptr<Kernel::KEvent> config_event; | 105 | Kernel::KEvent config_event; |
| 108 | }; | 106 | }; |
| 109 | 107 | ||
| 110 | class BTM_USR final : public ServiceFramework<BTM_USR> { | 108 | class BTM_USR final : public ServiceFramework<BTM_USR> { |
diff --git a/src/core/hle/service/friend/friend.cpp b/src/core/hle/service/friend/friend.cpp index a35979053..526b0f896 100644 --- a/src/core/hle/service/friend/friend.cpp +++ b/src/core/hle/service/friend/friend.cpp | |||
| @@ -185,7 +185,8 @@ private: | |||
| 185 | class INotificationService final : public ServiceFramework<INotificationService> { | 185 | class INotificationService final : public ServiceFramework<INotificationService> { |
| 186 | public: | 186 | public: |
| 187 | explicit INotificationService(Common::UUID uuid_, Core::System& system_) | 187 | explicit INotificationService(Common::UUID uuid_, Core::System& system_) |
| 188 | : ServiceFramework{system_, "INotificationService"}, uuid{uuid_} { | 188 | : ServiceFramework{system_, "INotificationService"}, uuid{uuid_}, notification_event{ |
| 189 | system.Kernel()} { | ||
| 189 | // clang-format off | 190 | // clang-format off |
| 190 | static const FunctionInfo functions[] = { | 191 | static const FunctionInfo functions[] = { |
| 191 | {0, &INotificationService::GetEvent, "GetEvent"}, | 192 | {0, &INotificationService::GetEvent, "GetEvent"}, |
| @@ -196,9 +197,7 @@ public: | |||
| 196 | 197 | ||
| 197 | RegisterHandlers(functions); | 198 | RegisterHandlers(functions); |
| 198 | 199 | ||
| 199 | notification_event = | 200 | notification_event.Initialize("INotificationService:NotifyEvent"); |
| 200 | Kernel::KEvent::Create(system.Kernel(), "INotificationService:NotifyEvent"); | ||
| 201 | notification_event->Initialize(); | ||
| 202 | } | 201 | } |
| 203 | 202 | ||
| 204 | private: | 203 | private: |
| @@ -207,7 +206,7 @@ private: | |||
| 207 | 206 | ||
| 208 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 207 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 209 | rb.Push(RESULT_SUCCESS); | 208 | rb.Push(RESULT_SUCCESS); |
| 210 | rb.PushCopyObjects(notification_event->GetReadableEvent()); | 209 | rb.PushCopyObjects(notification_event.GetReadableEvent()); |
| 211 | } | 210 | } |
| 212 | 211 | ||
| 213 | void Clear(Kernel::HLERequestContext& ctx) { | 212 | void Clear(Kernel::HLERequestContext& ctx) { |
| @@ -273,7 +272,7 @@ private: | |||
| 273 | }; | 272 | }; |
| 274 | 273 | ||
| 275 | Common::UUID uuid{Common::INVALID_UUID}; | 274 | Common::UUID uuid{Common::INVALID_UUID}; |
| 276 | std::shared_ptr<Kernel::KEvent> notification_event; | 275 | Kernel::KEvent notification_event; |
| 277 | std::queue<SizedNotificationInfo> notifications; | 276 | std::queue<SizedNotificationInfo> notifications; |
| 278 | States states{}; | 277 | States states{}; |
| 279 | }; | 278 | }; |
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 9d07ca09c..7d9debc09 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp | |||
| @@ -253,9 +253,8 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) { | |||
| 253 | void Controller_NPad::OnInit() { | 253 | void Controller_NPad::OnInit() { |
| 254 | auto& kernel = system.Kernel(); | 254 | auto& kernel = system.Kernel(); |
| 255 | for (std::size_t i = 0; i < styleset_changed_events.size(); ++i) { | 255 | for (std::size_t i = 0; i < styleset_changed_events.size(); ++i) { |
| 256 | styleset_changed_events[i] = | 256 | styleset_changed_events[i] = std::make_unique<Kernel::KEvent>(kernel); |
| 257 | Kernel::KEvent::Create(kernel, fmt::format("npad:NpadStyleSetChanged_{}", i)); | 257 | styleset_changed_events[i]->Initialize(fmt::format("npad:NpadStyleSetChanged_{}", i)); |
| 258 | styleset_changed_events[i]->Initialize(); | ||
| 259 | } | 258 | } |
| 260 | 259 | ||
| 261 | if (!IsControllerActivated()) { | 260 | if (!IsControllerActivated()) { |
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 8c24728b1..515cf7c37 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h | |||
| @@ -573,7 +573,7 @@ private: | |||
| 573 | NpadHandheldActivationMode handheld_activation_mode{NpadHandheldActivationMode::Dual}; | 573 | NpadHandheldActivationMode handheld_activation_mode{NpadHandheldActivationMode::Dual}; |
| 574 | NpadCommunicationMode communication_mode{NpadCommunicationMode::Default}; | 574 | NpadCommunicationMode communication_mode{NpadCommunicationMode::Default}; |
| 575 | // Each controller should have their own styleset changed event | 575 | // Each controller should have their own styleset changed event |
| 576 | std::array<std::shared_ptr<Kernel::KEvent>, 10> styleset_changed_events; | 576 | std::array<std::unique_ptr<Kernel::KEvent>, 10> styleset_changed_events; |
| 577 | std::array<std::array<std::chrono::steady_clock::time_point, 2>, 10> last_vibration_timepoints; | 577 | std::array<std::array<std::chrono::steady_clock::time_point, 2>, 10> last_vibration_timepoints; |
| 578 | std::array<std::array<VibrationValue, 2>, 10> latest_vibration_values{}; | 578 | std::array<std::array<VibrationValue, 2>, 10> latest_vibration_values{}; |
| 579 | bool permit_vibration_session_enabled{false}; | 579 | 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 1446c0bcf..164b8b9cd 100644 --- a/src/core/hle/service/nfp/nfp.cpp +++ b/src/core/hle/service/nfp/nfp.cpp | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 9 | #include "core/core.h" | 9 | #include "core/core.h" |
| 10 | #include "core/hle/ipc_helpers.h" | 10 | #include "core/hle/ipc_helpers.h" |
| 11 | #include "core/hle/kernel/k_event.h" | ||
| 12 | #include "core/hle/kernel/k_readable_event.h" | 11 | #include "core/hle/kernel/k_readable_event.h" |
| 13 | #include "core/hle/kernel/k_thread.h" | 12 | #include "core/hle/kernel/k_thread.h" |
| 14 | #include "core/hle/kernel/k_writable_event.h" | 13 | #include "core/hle/kernel/k_writable_event.h" |
| @@ -24,10 +23,8 @@ constexpr ResultCode ERR_NO_APPLICATION_AREA(ErrorModule::NFP, 152); | |||
| 24 | 23 | ||
| 25 | Module::Interface::Interface(std::shared_ptr<Module> module_, Core::System& system_, | 24 | Module::Interface::Interface(std::shared_ptr<Module> module_, Core::System& system_, |
| 26 | const char* name) | 25 | const char* name) |
| 27 | : ServiceFramework{system_, name}, module{std::move(module_)} { | 26 | : ServiceFramework{system_, name}, nfc_tag_load{system.Kernel()}, module{std::move(module_)} { |
| 28 | auto& kernel = system.Kernel(); | 27 | nfc_tag_load.Initialize("IUser:NFCTagDetected"); |
| 29 | nfc_tag_load = Kernel::KEvent::Create(kernel, "IUser:NFCTagDetected"); | ||
| 30 | nfc_tag_load->Initialize(); | ||
| 31 | } | 28 | } |
| 32 | 29 | ||
| 33 | Module::Interface::~Interface() = default; | 30 | Module::Interface::~Interface() = default; |
| @@ -35,7 +32,8 @@ Module::Interface::~Interface() = default; | |||
| 35 | class IUser final : public ServiceFramework<IUser> { | 32 | class IUser final : public ServiceFramework<IUser> { |
| 36 | public: | 33 | public: |
| 37 | explicit IUser(Module::Interface& nfp_interface_, Core::System& system_) | 34 | explicit IUser(Module::Interface& nfp_interface_, Core::System& system_) |
| 38 | : ServiceFramework{system_, "NFP::IUser"}, nfp_interface{nfp_interface_} { | 35 | : ServiceFramework{system_, "NFP::IUser"}, nfp_interface{nfp_interface_}, |
| 36 | deactivate_event{system.Kernel()}, availability_change_event{system.Kernel()} { | ||
| 39 | static const FunctionInfo functions[] = { | 37 | static const FunctionInfo functions[] = { |
| 40 | {0, &IUser::Initialize, "Initialize"}, | 38 | {0, &IUser::Initialize, "Initialize"}, |
| 41 | {1, &IUser::Finalize, "Finalize"}, | 39 | {1, &IUser::Finalize, "Finalize"}, |
| @@ -65,11 +63,8 @@ public: | |||
| 65 | }; | 63 | }; |
| 66 | RegisterHandlers(functions); | 64 | RegisterHandlers(functions); |
| 67 | 65 | ||
| 68 | auto& kernel = system.Kernel(); | 66 | deactivate_event.Initialize("IUser:DeactivateEvent"); |
| 69 | deactivate_event = Kernel::KEvent::Create(kernel, "IUser:DeactivateEvent"); | 67 | availability_change_event.Initialize("IUser:AvailabilityChangeEvent"); |
| 70 | deactivate_event->Initialize(); | ||
| 71 | availability_change_event = Kernel::KEvent::Create(kernel, "IUser:AvailabilityChangeEvent"); | ||
| 72 | availability_change_event->Initialize(); | ||
| 73 | } | 68 | } |
| 74 | 69 | ||
| 75 | private: | 70 | private: |
| @@ -167,7 +162,7 @@ private: | |||
| 167 | 162 | ||
| 168 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 163 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 169 | rb.Push(RESULT_SUCCESS); | 164 | rb.Push(RESULT_SUCCESS); |
| 170 | rb.PushCopyObjects(deactivate_event->GetReadableEvent()); | 165 | rb.PushCopyObjects(deactivate_event.GetReadableEvent()); |
| 171 | } | 166 | } |
| 172 | 167 | ||
| 173 | void StopDetection(Kernel::HLERequestContext& ctx) { | 168 | void StopDetection(Kernel::HLERequestContext& ctx) { |
| @@ -176,7 +171,7 @@ private: | |||
| 176 | switch (device_state) { | 171 | switch (device_state) { |
| 177 | case DeviceState::TagFound: | 172 | case DeviceState::TagFound: |
| 178 | case DeviceState::TagNearby: | 173 | case DeviceState::TagNearby: |
| 179 | deactivate_event->GetWritableEvent()->Signal(); | 174 | deactivate_event.GetWritableEvent()->Signal(); |
| 180 | device_state = DeviceState::Initialized; | 175 | device_state = DeviceState::Initialized; |
| 181 | break; | 176 | break; |
| 182 | case DeviceState::SearchingForTag: | 177 | case DeviceState::SearchingForTag: |
| @@ -265,7 +260,7 @@ private: | |||
| 265 | 260 | ||
| 266 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 261 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 267 | rb.Push(RESULT_SUCCESS); | 262 | rb.Push(RESULT_SUCCESS); |
| 268 | rb.PushCopyObjects(availability_change_event->GetReadableEvent()); | 263 | rb.PushCopyObjects(availability_change_event.GetReadableEvent()); |
| 269 | } | 264 | } |
| 270 | 265 | ||
| 271 | void GetRegisterInfo(Kernel::HLERequestContext& ctx) { | 266 | void GetRegisterInfo(Kernel::HLERequestContext& ctx) { |
| @@ -319,9 +314,9 @@ private: | |||
| 319 | const u32 npad_id{0}; // Player 1 controller | 314 | const u32 npad_id{0}; // Player 1 controller |
| 320 | State state{State::NonInitialized}; | 315 | State state{State::NonInitialized}; |
| 321 | DeviceState device_state{DeviceState::Initialized}; | 316 | DeviceState device_state{DeviceState::Initialized}; |
| 322 | std::shared_ptr<Kernel::KEvent> deactivate_event; | ||
| 323 | std::shared_ptr<Kernel::KEvent> availability_change_event; | ||
| 324 | const Module::Interface& nfp_interface; | 317 | const Module::Interface& nfp_interface; |
| 318 | Kernel::KEvent deactivate_event; | ||
| 319 | Kernel::KEvent availability_change_event; | ||
| 325 | }; | 320 | }; |
| 326 | 321 | ||
| 327 | void Module::Interface::CreateUserInterface(Kernel::HLERequestContext& ctx) { | 322 | void Module::Interface::CreateUserInterface(Kernel::HLERequestContext& ctx) { |
| @@ -339,12 +334,12 @@ bool Module::Interface::LoadAmiibo(const std::vector<u8>& buffer) { | |||
| 339 | } | 334 | } |
| 340 | 335 | ||
| 341 | std::memcpy(&amiibo, buffer.data(), sizeof(amiibo)); | 336 | std::memcpy(&amiibo, buffer.data(), sizeof(amiibo)); |
| 342 | nfc_tag_load->GetWritableEvent()->Signal(); | 337 | nfc_tag_load.GetWritableEvent()->Signal(); |
| 343 | return true; | 338 | return true; |
| 344 | } | 339 | } |
| 345 | 340 | ||
| 346 | Kernel::KReadableEvent* Module::Interface::GetNFCEvent() const { | 341 | Kernel::KReadableEvent* Module::Interface::GetNFCEvent() const { |
| 347 | return nfc_tag_load->GetReadableEvent(); | 342 | return nfc_tag_load.GetReadableEvent().get(); |
| 348 | } | 343 | } |
| 349 | 344 | ||
| 350 | const Module::Interface::AmiiboFile& Module::Interface::GetAmiiboBuffer() const { | 345 | 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 7a97caffb..4bca2192c 100644 --- a/src/core/hle/service/nfp/nfp.h +++ b/src/core/hle/service/nfp/nfp.h | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <vector> | 8 | #include <vector> |
| 9 | 9 | ||
| 10 | #include "core/hle/kernel/k_event.h" | ||
| 10 | #include "core/hle/service/service.h" | 11 | #include "core/hle/service/service.h" |
| 11 | 12 | ||
| 12 | namespace Kernel { | 13 | namespace Kernel { |
| @@ -42,7 +43,7 @@ public: | |||
| 42 | const AmiiboFile& GetAmiiboBuffer() const; | 43 | const AmiiboFile& GetAmiiboBuffer() const; |
| 43 | 44 | ||
| 44 | private: | 45 | private: |
| 45 | std::shared_ptr<Kernel::KEvent> nfc_tag_load; | 46 | Kernel::KEvent nfc_tag_load; |
| 46 | AmiiboFile amiibo{}; | 47 | AmiiboFile amiibo{}; |
| 47 | 48 | ||
| 48 | protected: | 49 | protected: |
diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp index 9f110df8e..fe1c25757 100644 --- a/src/core/hle/service/nifm/nifm.cpp +++ b/src/core/hle/service/nifm/nifm.cpp | |||
| @@ -127,7 +127,8 @@ public: | |||
| 127 | 127 | ||
| 128 | class IRequest final : public ServiceFramework<IRequest> { | 128 | class IRequest final : public ServiceFramework<IRequest> { |
| 129 | public: | 129 | public: |
| 130 | explicit IRequest(Core::System& system_) : ServiceFramework{system_, "IRequest"} { | 130 | explicit IRequest(Core::System& system_) |
| 131 | : ServiceFramework{system_, "IRequest"}, event1{system.Kernel()}, event2{system.Kernel()} { | ||
| 131 | static const FunctionInfo functions[] = { | 132 | static const FunctionInfo functions[] = { |
| 132 | {0, &IRequest::GetRequestState, "GetRequestState"}, | 133 | {0, &IRequest::GetRequestState, "GetRequestState"}, |
| 133 | {1, &IRequest::GetResult, "GetResult"}, | 134 | {1, &IRequest::GetResult, "GetResult"}, |
| @@ -159,10 +160,8 @@ public: | |||
| 159 | 160 | ||
| 160 | auto& kernel = system.Kernel(); | 161 | auto& kernel = system.Kernel(); |
| 161 | 162 | ||
| 162 | event1 = Kernel::KEvent::Create(kernel, "IRequest:Event1"); | 163 | event1.Initialize("IRequest:Event1"); |
| 163 | event1->Initialize(); | 164 | event2.Initialize("IRequest:Event2"); |
| 164 | event2 = Kernel::KEvent::Create(kernel, "IRequest:Event2"); | ||
| 165 | event2->Initialize(); | ||
| 166 | } | 165 | } |
| 167 | 166 | ||
| 168 | private: | 167 | private: |
| @@ -198,7 +197,7 @@ private: | |||
| 198 | 197 | ||
| 199 | IPC::ResponseBuilder rb{ctx, 2, 2}; | 198 | IPC::ResponseBuilder rb{ctx, 2, 2}; |
| 200 | rb.Push(RESULT_SUCCESS); | 199 | rb.Push(RESULT_SUCCESS); |
| 201 | rb.PushCopyObjects(event1->GetReadableEvent(), event2->GetReadableEvent()); | 200 | rb.PushCopyObjects(event1.GetReadableEvent(), event2.GetReadableEvent()); |
| 202 | } | 201 | } |
| 203 | 202 | ||
| 204 | void Cancel(Kernel::HLERequestContext& ctx) { | 203 | void Cancel(Kernel::HLERequestContext& ctx) { |
| @@ -229,7 +228,7 @@ private: | |||
| 229 | rb.Push<u32>(0); | 228 | rb.Push<u32>(0); |
| 230 | } | 229 | } |
| 231 | 230 | ||
| 232 | std::shared_ptr<Kernel::KEvent> event1, event2; | 231 | Kernel::KEvent event1, event2; |
| 233 | }; | 232 | }; |
| 234 | 233 | ||
| 235 | class INetworkProfile final : public ServiceFramework<INetworkProfile> { | 234 | class INetworkProfile final : public ServiceFramework<INetworkProfile> { |
diff --git a/src/core/hle/service/nim/nim.cpp b/src/core/hle/service/nim/nim.cpp index fee360ab9..6d66ad90b 100644 --- a/src/core/hle/service/nim/nim.cpp +++ b/src/core/hle/service/nim/nim.cpp | |||
| @@ -300,7 +300,8 @@ class IEnsureNetworkClockAvailabilityService final | |||
| 300 | : public ServiceFramework<IEnsureNetworkClockAvailabilityService> { | 300 | : public ServiceFramework<IEnsureNetworkClockAvailabilityService> { |
| 301 | public: | 301 | public: |
| 302 | explicit IEnsureNetworkClockAvailabilityService(Core::System& system_) | 302 | explicit IEnsureNetworkClockAvailabilityService(Core::System& system_) |
| 303 | : ServiceFramework{system_, "IEnsureNetworkClockAvailabilityService"} { | 303 | : ServiceFramework{system_, "IEnsureNetworkClockAvailabilityService"}, |
| 304 | finished_event{system.Kernel()} { | ||
| 304 | static const FunctionInfo functions[] = { | 305 | static const FunctionInfo functions[] = { |
| 305 | {0, &IEnsureNetworkClockAvailabilityService::StartTask, "StartTask"}, | 306 | {0, &IEnsureNetworkClockAvailabilityService::StartTask, "StartTask"}, |
| 306 | {1, &IEnsureNetworkClockAvailabilityService::GetFinishNotificationEvent, | 307 | {1, &IEnsureNetworkClockAvailabilityService::GetFinishNotificationEvent, |
| @@ -312,19 +313,16 @@ public: | |||
| 312 | }; | 313 | }; |
| 313 | RegisterHandlers(functions); | 314 | RegisterHandlers(functions); |
| 314 | 315 | ||
| 315 | auto& kernel = system.Kernel(); | 316 | finished_event.Initialize("IEnsureNetworkClockAvailabilityService:FinishEvent"); |
| 316 | finished_event = | ||
| 317 | Kernel::KEvent::Create(kernel, "IEnsureNetworkClockAvailabilityService:FinishEvent"); | ||
| 318 | finished_event->Initialize(); | ||
| 319 | } | 317 | } |
| 320 | 318 | ||
| 321 | private: | 319 | private: |
| 322 | std::shared_ptr<Kernel::KEvent> finished_event; | 320 | Kernel::KEvent finished_event; |
| 323 | 321 | ||
| 324 | void StartTask(Kernel::HLERequestContext& ctx) { | 322 | void StartTask(Kernel::HLERequestContext& ctx) { |
| 325 | // No need to connect to the internet, just finish the task straight away. | 323 | // No need to connect to the internet, just finish the task straight away. |
| 326 | LOG_DEBUG(Service_NIM, "called"); | 324 | LOG_DEBUG(Service_NIM, "called"); |
| 327 | finished_event->GetWritableEvent()->Signal(); | 325 | finished_event.GetWritableEvent()->Signal(); |
| 328 | IPC::ResponseBuilder rb{ctx, 2}; | 326 | IPC::ResponseBuilder rb{ctx, 2}; |
| 329 | rb.Push(RESULT_SUCCESS); | 327 | rb.Push(RESULT_SUCCESS); |
| 330 | } | 328 | } |
| @@ -334,7 +332,7 @@ private: | |||
| 334 | 332 | ||
| 335 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 333 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 336 | rb.Push(RESULT_SUCCESS); | 334 | rb.Push(RESULT_SUCCESS); |
| 337 | rb.PushCopyObjects(finished_event->GetReadableEvent()); | 335 | rb.PushCopyObjects(finished_event.GetReadableEvent()); |
| 338 | } | 336 | } |
| 339 | 337 | ||
| 340 | void GetResult(Kernel::HLERequestContext& ctx) { | 338 | void GetResult(Kernel::HLERequestContext& ctx) { |
| @@ -346,7 +344,7 @@ private: | |||
| 346 | 344 | ||
| 347 | void Cancel(Kernel::HLERequestContext& ctx) { | 345 | void Cancel(Kernel::HLERequestContext& ctx) { |
| 348 | LOG_DEBUG(Service_NIM, "called"); | 346 | LOG_DEBUG(Service_NIM, "called"); |
| 349 | finished_event->GetWritableEvent()->Clear(); | 347 | finished_event.GetWritableEvent()->Clear(); |
| 350 | IPC::ResponseBuilder rb{ctx, 2}; | 348 | IPC::ResponseBuilder rb{ctx, 2}; |
| 351 | rb.Push(RESULT_SUCCESS); | 349 | rb.Push(RESULT_SUCCESS); |
| 352 | } | 350 | } |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp index 6f4007294..e99da24ab 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp | |||
| @@ -102,7 +102,7 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector | |||
| 102 | return NvResult::Success; | 102 | return NvResult::Success; |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | auto event = events_interface.events[event_id]; | 105 | auto& event = events_interface.events[event_id]; |
| 106 | auto& gpu = system.GPU(); | 106 | auto& gpu = system.GPU(); |
| 107 | 107 | ||
| 108 | // This is mostly to take into account unimplemented features. As synced | 108 | // This is mostly to take into account unimplemented features. As synced |
diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp index 6bba9c0b3..74399bcdb 100644 --- a/src/core/hle/service/nvdrv/nvdrv.cpp +++ b/src/core/hle/service/nvdrv/nvdrv.cpp | |||
| @@ -42,9 +42,8 @@ void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger | |||
| 42 | Module::Module(Core::System& system) : syncpoint_manager{system.GPU()} { | 42 | Module::Module(Core::System& system) : syncpoint_manager{system.GPU()} { |
| 43 | auto& kernel = system.Kernel(); | 43 | auto& kernel = system.Kernel(); |
| 44 | for (u32 i = 0; i < MaxNvEvents; i++) { | 44 | for (u32 i = 0; i < MaxNvEvents; i++) { |
| 45 | std::string event_label = fmt::format("NVDRV::NvEvent_{}", i); | 45 | events_interface.events[i].event = std::make_unique<Kernel::KEvent>(kernel); |
| 46 | events_interface.events[i] = {Kernel::KEvent::Create(kernel, std::move(event_label))}; | 46 | events_interface.events[i].event->Initialize(fmt::format("NVDRV::NvEvent_{}", i)); |
| 47 | events_interface.events[i].event->Initialize(); | ||
| 48 | events_interface.status[i] = EventState::Free; | 47 | events_interface.status[i] = EventState::Free; |
| 49 | events_interface.registered[i] = false; | 48 | events_interface.registered[i] = false; |
| 50 | } | 49 | } |
| @@ -64,7 +63,12 @@ Module::Module(Core::System& system) : syncpoint_manager{system.GPU()} { | |||
| 64 | std::make_shared<Devices::nvhost_vic>(system, nvmap_dev, syncpoint_manager); | 63 | std::make_shared<Devices::nvhost_vic>(system, nvmap_dev, syncpoint_manager); |
| 65 | } | 64 | } |
| 66 | 65 | ||
| 67 | Module::~Module() = default; | 66 | Module::~Module() { |
| 67 | for (u32 i = 0; i < MaxNvEvents; i++) { | ||
| 68 | events_interface.events[i].event->Close(); | ||
| 69 | events_interface.events[i].event = nullptr; | ||
| 70 | } | ||
| 71 | } | ||
| 68 | 72 | ||
| 69 | NvResult Module::VerifyFD(DeviceFD fd) const { | 73 | NvResult Module::VerifyFD(DeviceFD fd) const { |
| 70 | if (fd < 0) { | 74 | if (fd < 0) { |
diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h index 53719aadd..76f77cbb1 100644 --- a/src/core/hle/service/nvdrv/nvdrv.h +++ b/src/core/hle/service/nvdrv/nvdrv.h | |||
| @@ -35,7 +35,7 @@ class nvdevice; | |||
| 35 | 35 | ||
| 36 | /// Represents an Nvidia event | 36 | /// Represents an Nvidia event |
| 37 | struct NvEvent { | 37 | struct NvEvent { |
| 38 | std::shared_ptr<Kernel::KEvent> event; | 38 | std::unique_ptr<Kernel::KEvent> event; |
| 39 | Fence fence{}; | 39 | Fence fence{}; |
| 40 | }; | 40 | }; |
| 41 | 41 | ||
diff --git a/src/core/hle/service/nvflinger/buffer_queue.cpp b/src/core/hle/service/nvflinger/buffer_queue.cpp index f783ae54f..8ddb1f908 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.cpp +++ b/src/core/hle/service/nvflinger/buffer_queue.cpp | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | #include "common/assert.h" | 7 | #include "common/assert.h" |
| 8 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 9 | #include "core/core.h" | 9 | #include "core/core.h" |
| 10 | #include "core/hle/kernel/k_event.h" | ||
| 11 | #include "core/hle/kernel/k_writable_event.h" | 10 | #include "core/hle/kernel/k_writable_event.h" |
| 12 | #include "core/hle/kernel/kernel.h" | 11 | #include "core/hle/kernel/kernel.h" |
| 13 | #include "core/hle/service/nvflinger/buffer_queue.h" | 12 | #include "core/hle/service/nvflinger/buffer_queue.h" |
| @@ -15,9 +14,8 @@ | |||
| 15 | namespace Service::NVFlinger { | 14 | namespace Service::NVFlinger { |
| 16 | 15 | ||
| 17 | BufferQueue::BufferQueue(Kernel::KernelCore& kernel, u32 id, u64 layer_id) | 16 | BufferQueue::BufferQueue(Kernel::KernelCore& kernel, u32 id, u64 layer_id) |
| 18 | : id(id), layer_id(layer_id) { | 17 | : id(id), layer_id(layer_id), buffer_wait_event{kernel} { |
| 19 | buffer_wait_event = Kernel::KEvent::Create(kernel, "BufferQueue:WaitEvent"); | 18 | buffer_wait_event.Initialize("BufferQueue:WaitEvent"); |
| 20 | buffer_wait_event->Initialize(); | ||
| 21 | } | 19 | } |
| 22 | 20 | ||
| 23 | BufferQueue::~BufferQueue() = default; | 21 | BufferQueue::~BufferQueue() = default; |
| @@ -42,7 +40,7 @@ void BufferQueue::SetPreallocatedBuffer(u32 slot, const IGBPBuffer& igbp_buffer) | |||
| 42 | .multi_fence = {}, | 40 | .multi_fence = {}, |
| 43 | }; | 41 | }; |
| 44 | 42 | ||
| 45 | buffer_wait_event->GetWritableEvent()->Signal(); | 43 | buffer_wait_event.GetWritableEvent()->Signal(); |
| 46 | } | 44 | } |
| 47 | 45 | ||
| 48 | std::optional<std::pair<u32, Service::Nvidia::MultiFence*>> BufferQueue::DequeueBuffer(u32 width, | 46 | std::optional<std::pair<u32, Service::Nvidia::MultiFence*>> BufferQueue::DequeueBuffer(u32 width, |
| @@ -120,7 +118,7 @@ void BufferQueue::CancelBuffer(u32 slot, const Service::Nvidia::MultiFence& mult | |||
| 120 | } | 118 | } |
| 121 | free_buffers_condition.notify_one(); | 119 | free_buffers_condition.notify_one(); |
| 122 | 120 | ||
| 123 | buffer_wait_event->GetWritableEvent()->Signal(); | 121 | buffer_wait_event.GetWritableEvent()->Signal(); |
| 124 | } | 122 | } |
| 125 | 123 | ||
| 126 | std::optional<std::reference_wrapper<const BufferQueue::Buffer>> BufferQueue::AcquireBuffer() { | 124 | std::optional<std::reference_wrapper<const BufferQueue::Buffer>> BufferQueue::AcquireBuffer() { |
| @@ -155,7 +153,7 @@ void BufferQueue::ReleaseBuffer(u32 slot) { | |||
| 155 | } | 153 | } |
| 156 | free_buffers_condition.notify_one(); | 154 | free_buffers_condition.notify_one(); |
| 157 | 155 | ||
| 158 | buffer_wait_event->GetWritableEvent()->Signal(); | 156 | buffer_wait_event.GetWritableEvent()->Signal(); |
| 159 | } | 157 | } |
| 160 | 158 | ||
| 161 | void BufferQueue::Connect() { | 159 | void BufferQueue::Connect() { |
| @@ -170,7 +168,7 @@ void BufferQueue::Disconnect() { | |||
| 170 | std::unique_lock lock{queue_sequence_mutex}; | 168 | std::unique_lock lock{queue_sequence_mutex}; |
| 171 | queue_sequence.clear(); | 169 | queue_sequence.clear(); |
| 172 | } | 170 | } |
| 173 | buffer_wait_event->GetWritableEvent()->Signal(); | 171 | buffer_wait_event.GetWritableEvent()->Signal(); |
| 174 | is_connect = false; | 172 | is_connect = false; |
| 175 | free_buffers_condition.notify_one(); | 173 | free_buffers_condition.notify_one(); |
| 176 | } | 174 | } |
| @@ -190,11 +188,11 @@ u32 BufferQueue::Query(QueryType type) { | |||
| 190 | } | 188 | } |
| 191 | 189 | ||
| 192 | std::shared_ptr<Kernel::KWritableEvent> BufferQueue::GetWritableBufferWaitEvent() const { | 190 | std::shared_ptr<Kernel::KWritableEvent> BufferQueue::GetWritableBufferWaitEvent() const { |
| 193 | return buffer_wait_event->GetWritableEvent(); | 191 | return buffer_wait_event.GetWritableEvent(); |
| 194 | } | 192 | } |
| 195 | 193 | ||
| 196 | std::shared_ptr<Kernel::KReadableEvent> BufferQueue::GetBufferWaitEvent() const { | 194 | std::shared_ptr<Kernel::KReadableEvent> BufferQueue::GetBufferWaitEvent() const { |
| 197 | return SharedFrom(buffer_wait_event->GetReadableEvent()); | 195 | return buffer_wait_event.GetReadableEvent(); |
| 198 | } | 196 | } |
| 199 | 197 | ||
| 200 | } // namespace Service::NVFlinger | 198 | } // namespace Service::NVFlinger |
diff --git a/src/core/hle/service/nvflinger/buffer_queue.h b/src/core/hle/service/nvflinger/buffer_queue.h index 9a21c7426..0d2010ad5 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.h +++ b/src/core/hle/service/nvflinger/buffer_queue.h | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #include "common/common_funcs.h" | 13 | #include "common/common_funcs.h" |
| 14 | #include "common/math_util.h" | 14 | #include "common/math_util.h" |
| 15 | #include "common/swap.h" | 15 | #include "common/swap.h" |
| 16 | #include "core/hle/kernel/k_event.h" | ||
| 16 | #include "core/hle/kernel/k_readable_event.h" | 17 | #include "core/hle/kernel/k_readable_event.h" |
| 17 | #include "core/hle/kernel/object.h" | 18 | #include "core/hle/kernel/object.h" |
| 18 | #include "core/hle/service/nvdrv/nvdata.h" | 19 | #include "core/hle/service/nvdrv/nvdata.h" |
| @@ -130,7 +131,7 @@ private: | |||
| 130 | std::list<u32> free_buffers; | 131 | std::list<u32> free_buffers; |
| 131 | std::array<Buffer, buffer_slots> buffers; | 132 | std::array<Buffer, buffer_slots> buffers; |
| 132 | std::list<u32> queue_sequence; | 133 | std::list<u32> queue_sequence; |
| 133 | std::shared_ptr<Kernel::KEvent> buffer_wait_event; | 134 | Kernel::KEvent buffer_wait_event; |
| 134 | 135 | ||
| 135 | std::mutex free_buffers_mutex; | 136 | std::mutex free_buffers_mutex; |
| 136 | std::condition_variable free_buffers_condition; | 137 | std::condition_variable free_buffers_condition; |
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index c43593e7f..c90e4d083 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp | |||
| @@ -165,8 +165,8 @@ std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) co | |||
| 165 | return layer->GetBufferQueue().GetId(); | 165 | return layer->GetBufferQueue().GetId(); |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | std::shared_ptr<Kernel::KReadableEvent> NVFlinger::FindVsyncEvent(u64 display_id) const { | 168 | std::shared_ptr<Kernel::KReadableEvent> NVFlinger::FindVsyncEvent(u64 display_id) { |
| 169 | const auto lock_guard = Lock(); | 169 | const auto lock_guard = Lock(); |
| 170 | auto* const display = FindDisplay(display_id); | 170 | auto* const display = FindDisplay(display_id); |
| 171 | 171 | ||
| 172 | if (display == nullptr) { | 172 | if (display == nullptr) { |
diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h index 6fe2c7f2a..d51b905c1 100644 --- a/src/core/hle/service/nvflinger/nvflinger.h +++ b/src/core/hle/service/nvflinger/nvflinger.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <atomic> | 7 | #include <atomic> |
| 8 | #include <list> | ||
| 8 | #include <memory> | 9 | #include <memory> |
| 9 | #include <mutex> | 10 | #include <mutex> |
| 10 | #include <optional> | 11 | #include <optional> |
| @@ -72,7 +73,7 @@ public: | |||
| 72 | /// Gets the vsync event for the specified display. | 73 | /// Gets the vsync event for the specified display. |
| 73 | /// | 74 | /// |
| 74 | /// If an invalid display ID is provided, then nullptr is returned. | 75 | /// If an invalid display ID is provided, then nullptr is returned. |
| 75 | [[nodiscard]] std::shared_ptr<Kernel::KReadableEvent> FindVsyncEvent(u64 display_id) const; | 76 | [[nodiscard]] std::shared_ptr<Kernel::KReadableEvent> FindVsyncEvent(u64 display_id); |
| 76 | 77 | ||
| 77 | /// Obtains a buffer queue identified by the ID. | 78 | /// Obtains a buffer queue identified by the ID. |
| 78 | [[nodiscard]] BufferQueue* FindBufferQueue(u32 id); | 79 | [[nodiscard]] BufferQueue* FindBufferQueue(u32 id); |
| @@ -106,7 +107,7 @@ private: | |||
| 106 | 107 | ||
| 107 | std::shared_ptr<Nvidia::Module> nvdrv; | 108 | std::shared_ptr<Nvidia::Module> nvdrv; |
| 108 | 109 | ||
| 109 | std::vector<VI::Display> displays; | 110 | std::list<VI::Display> displays; |
| 110 | std::vector<std::unique_ptr<BufferQueue>> buffer_queues; | 111 | std::vector<std::unique_ptr<BufferQueue>> buffer_queues; |
| 111 | 112 | ||
| 112 | /// Id to use for the next layer that is created, this counter is shared among all displays. | 113 | /// Id to use for the next layer that is created, this counter is shared among all displays. |
diff --git a/src/core/hle/service/ptm/psm.cpp b/src/core/hle/service/ptm/psm.cpp index 26ed52273..22e5d9749 100644 --- a/src/core/hle/service/ptm/psm.cpp +++ b/src/core/hle/service/ptm/psm.cpp | |||
| @@ -19,7 +19,8 @@ namespace Service::PSM { | |||
| 19 | 19 | ||
| 20 | class IPsmSession final : public ServiceFramework<IPsmSession> { | 20 | class IPsmSession final : public ServiceFramework<IPsmSession> { |
| 21 | public: | 21 | public: |
| 22 | explicit IPsmSession(Core::System& system_) : ServiceFramework{system_, "IPsmSession"} { | 22 | explicit IPsmSession(Core::System& system_) |
| 23 | : ServiceFramework{system_, "IPsmSession"}, state_change_event{system.Kernel()} { | ||
| 23 | // clang-format off | 24 | // clang-format off |
| 24 | static const FunctionInfo functions[] = { | 25 | static const FunctionInfo functions[] = { |
| 25 | {0, &IPsmSession::BindStateChangeEvent, "BindStateChangeEvent"}, | 26 | {0, &IPsmSession::BindStateChangeEvent, "BindStateChangeEvent"}, |
| @@ -32,28 +33,26 @@ public: | |||
| 32 | 33 | ||
| 33 | RegisterHandlers(functions); | 34 | RegisterHandlers(functions); |
| 34 | 35 | ||
| 35 | state_change_event = | 36 | state_change_event.Initialize("IPsmSession::state_change_event"); |
| 36 | Kernel::KEvent::Create(system_.Kernel(), "IPsmSession::state_change_event"); | ||
| 37 | state_change_event->Initialize(); | ||
| 38 | } | 37 | } |
| 39 | 38 | ||
| 40 | ~IPsmSession() override = default; | 39 | ~IPsmSession() override = default; |
| 41 | 40 | ||
| 42 | void SignalChargerTypeChanged() { | 41 | void SignalChargerTypeChanged() { |
| 43 | if (should_signal && should_signal_charger_type) { | 42 | if (should_signal && should_signal_charger_type) { |
| 44 | state_change_event->GetWritableEvent()->Signal(); | 43 | state_change_event.GetWritableEvent()->Signal(); |
| 45 | } | 44 | } |
| 46 | } | 45 | } |
| 47 | 46 | ||
| 48 | void SignalPowerSupplyChanged() { | 47 | void SignalPowerSupplyChanged() { |
| 49 | if (should_signal && should_signal_power_supply) { | 48 | if (should_signal && should_signal_power_supply) { |
| 50 | state_change_event->GetWritableEvent()->Signal(); | 49 | state_change_event.GetWritableEvent()->Signal(); |
| 51 | } | 50 | } |
| 52 | } | 51 | } |
| 53 | 52 | ||
| 54 | void SignalBatteryVoltageStateChanged() { | 53 | void SignalBatteryVoltageStateChanged() { |
| 55 | if (should_signal && should_signal_battery_voltage) { | 54 | if (should_signal && should_signal_battery_voltage) { |
| 56 | state_change_event->GetWritableEvent()->Signal(); | 55 | state_change_event.GetWritableEvent()->Signal(); |
| 57 | } | 56 | } |
| 58 | } | 57 | } |
| 59 | 58 | ||
| @@ -65,7 +64,7 @@ private: | |||
| 65 | 64 | ||
| 66 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 65 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 67 | rb.Push(RESULT_SUCCESS); | 66 | rb.Push(RESULT_SUCCESS); |
| 68 | rb.PushCopyObjects(state_change_event->GetReadableEvent()); | 67 | rb.PushCopyObjects(state_change_event.GetReadableEvent()); |
| 69 | } | 68 | } |
| 70 | 69 | ||
| 71 | void UnbindStateChangeEvent(Kernel::HLERequestContext& ctx) { | 70 | void UnbindStateChangeEvent(Kernel::HLERequestContext& ctx) { |
| @@ -114,7 +113,7 @@ private: | |||
| 114 | bool should_signal_power_supply{}; | 113 | bool should_signal_power_supply{}; |
| 115 | bool should_signal_battery_voltage{}; | 114 | bool should_signal_battery_voltage{}; |
| 116 | bool should_signal{}; | 115 | bool should_signal{}; |
| 117 | std::shared_ptr<Kernel::KEvent> state_change_event; | 116 | Kernel::KEvent state_change_event; |
| 118 | }; | 117 | }; |
| 119 | 118 | ||
| 120 | class PSM final : public ServiceFramework<PSM> { | 119 | class PSM final : public ServiceFramework<PSM> { |
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 3172acc5a..c41bdd48b 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,6 @@ | |||
| 4 | 4 | ||
| 5 | #include "common/assert.h" | 5 | #include "common/assert.h" |
| 6 | #include "core/core.h" | 6 | #include "core/core.h" |
| 7 | #include "core/hle/kernel/k_event.h" | ||
| 8 | #include "core/hle/service/time/standard_local_system_clock_core.h" | 7 | #include "core/hle/service/time/standard_local_system_clock_core.h" |
| 9 | #include "core/hle/service/time/standard_network_system_clock_core.h" | 8 | #include "core/hle/service/time/standard_network_system_clock_core.h" |
| 10 | #include "core/hle/service/time/standard_user_system_clock_core.h" | 9 | #include "core/hle/service/time/standard_user_system_clock_core.h" |
| @@ -17,10 +16,9 @@ StandardUserSystemClockCore::StandardUserSystemClockCore( | |||
| 17 | : SystemClockCore(local_system_clock_core.GetSteadyClockCore()), | 16 | : SystemClockCore(local_system_clock_core.GetSteadyClockCore()), |
| 18 | local_system_clock_core{local_system_clock_core}, | 17 | local_system_clock_core{local_system_clock_core}, |
| 19 | network_system_clock_core{network_system_clock_core}, auto_correction_enabled{}, | 18 | network_system_clock_core{network_system_clock_core}, auto_correction_enabled{}, |
| 20 | auto_correction_time{SteadyClockTimePoint::GetRandom()}, | 19 | auto_correction_time{SteadyClockTimePoint::GetRandom()}, auto_correction_event{ |
| 21 | auto_correction_event{Kernel::KEvent::Create( | 20 | system.Kernel()} { |
| 22 | system.Kernel(), "StandardUserSystemClockCore:AutoCorrectionEvent")} { | 21 | auto_correction_event.Initialize("StandardUserSystemClockCore:AutoCorrectionEvent"); |
| 23 | auto_correction_event->Initialize(); | ||
| 24 | } | 22 | } |
| 25 | 23 | ||
| 26 | ResultCode StandardUserSystemClockCore::SetAutomaticCorrectionEnabled(Core::System& system, | 24 | 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 5bc8bf5c2..1bff8a5af 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,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include "core/hle/kernel/k_event.h" | ||
| 7 | #include "core/hle/service/time/clock_types.h" | 8 | #include "core/hle/service/time/clock_types.h" |
| 8 | #include "core/hle/service/time/system_clock_core.h" | 9 | #include "core/hle/service/time/system_clock_core.h" |
| 9 | 10 | ||
| @@ -54,7 +55,7 @@ private: | |||
| 54 | StandardNetworkSystemClockCore& network_system_clock_core; | 55 | StandardNetworkSystemClockCore& network_system_clock_core; |
| 55 | bool auto_correction_enabled{}; | 56 | bool auto_correction_enabled{}; |
| 56 | SteadyClockTimePoint auto_correction_time; | 57 | SteadyClockTimePoint auto_correction_time; |
| 57 | std::shared_ptr<Kernel::KEvent> auto_correction_event; | 58 | Kernel::KEvent auto_correction_event; |
| 58 | }; | 59 | }; |
| 59 | 60 | ||
| 60 | } // namespace Service::Time::Clock | 61 | } // 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 9ffa71352..ebaacaa6b 100644 --- a/src/core/hle/service/vi/display/vi_display.cpp +++ b/src/core/hle/service/vi/display/vi_display.cpp | |||
| @@ -17,10 +17,9 @@ | |||
| 17 | 17 | ||
| 18 | namespace Service::VI { | 18 | namespace Service::VI { |
| 19 | 19 | ||
| 20 | Display::Display(u64 id, std::string name, Core::System& system) : id{id}, name{std::move(name)} { | 20 | Display::Display(u64 id, std::string name, Core::System& system) |
| 21 | auto& kernel = system.Kernel(); | 21 | : id{id}, name{std::move(name)}, vsync_event{system.Kernel()} { |
| 22 | vsync_event = Kernel::KEvent::Create(kernel, fmt::format("Display VSync Event {}", id)); | 22 | vsync_event.Initialize(fmt::format("Display VSync Event {}", id)); |
| 23 | vsync_event->Initialize(); | ||
| 24 | } | 23 | } |
| 25 | 24 | ||
| 26 | Display::~Display() = default; | 25 | Display::~Display() = default; |
| @@ -34,11 +33,11 @@ const Layer& Display::GetLayer(std::size_t index) const { | |||
| 34 | } | 33 | } |
| 35 | 34 | ||
| 36 | std::shared_ptr<Kernel::KReadableEvent> Display::GetVSyncEvent() const { | 35 | std::shared_ptr<Kernel::KReadableEvent> Display::GetVSyncEvent() const { |
| 37 | return SharedFrom(vsync_event->GetReadableEvent()); | 36 | return vsync_event.GetReadableEvent(); |
| 38 | } | 37 | } |
| 39 | 38 | ||
| 40 | void Display::SignalVSyncEvent() { | 39 | void Display::SignalVSyncEvent() { |
| 41 | vsync_event->GetWritableEvent()->Signal(); | 40 | vsync_event.GetWritableEvent()->Signal(); |
| 42 | } | 41 | } |
| 43 | 42 | ||
| 44 | void Display::CreateLayer(u64 layer_id, NVFlinger::BufferQueue& buffer_queue) { | 43 | void Display::CreateLayer(u64 layer_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 8340059de..e990d6809 100644 --- a/src/core/hle/service/vi/display/vi_display.h +++ b/src/core/hle/service/vi/display/vi_display.h | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include <string> | 8 | #include <string> |
| 9 | #include <vector> | 9 | #include <vector> |
| 10 | 10 | ||
| 11 | #include "common/common_funcs.h" | ||
| 11 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 12 | 13 | ||
| 13 | namespace Kernel { | 14 | namespace Kernel { |
| @@ -24,6 +25,9 @@ class Layer; | |||
| 24 | 25 | ||
| 25 | /// Represents a single display type | 26 | /// Represents a single display type |
| 26 | class Display { | 27 | class Display { |
| 28 | NON_COPYABLE(Display); | ||
| 29 | NON_MOVEABLE(Display); | ||
| 30 | |||
| 27 | public: | 31 | public: |
| 28 | /// Constructs a display with a given unique ID and name. | 32 | /// Constructs a display with a given unique ID and name. |
| 29 | /// | 33 | /// |
| @@ -33,12 +37,6 @@ public: | |||
| 33 | Display(u64 id, std::string name, Core::System& system); | 37 | Display(u64 id, std::string name, Core::System& system); |
| 34 | ~Display(); | 38 | ~Display(); |
| 35 | 39 | ||
| 36 | Display(const Display&) = delete; | ||
| 37 | Display& operator=(const Display&) = delete; | ||
| 38 | |||
| 39 | Display(Display&&) = default; | ||
| 40 | Display& operator=(Display&&) = default; | ||
| 41 | |||
| 42 | /// Gets the unique ID assigned to this display. | 40 | /// Gets the unique ID assigned to this display. |
| 43 | u64 GetID() const { | 41 | u64 GetID() const { |
| 44 | return id; | 42 | return id; |
| @@ -102,7 +100,7 @@ private: | |||
| 102 | std::string name; | 100 | std::string name; |
| 103 | 101 | ||
| 104 | std::vector<std::shared_ptr<Layer>> layers; | 102 | std::vector<std::shared_ptr<Layer>> layers; |
| 105 | std::shared_ptr<Kernel::KEvent> vsync_event; | 103 | Kernel::KEvent vsync_event; |
| 106 | }; | 104 | }; |
| 107 | 105 | ||
| 108 | } // namespace Service::VI | 106 | } // namespace Service::VI |