From 5e5933256b022f6890fc3f14164ae9e9c3ee9ae3 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sat, 3 Apr 2021 21:21:22 -0700 Subject: hle: kernel: Refactor IPC interfaces to not use std::shared_ptr. --- src/core/hle/service/am/am.cpp | 5 ++--- src/core/hle/service/am/am.h | 4 ++-- src/core/hle/service/am/applets/applets.cpp | 6 +++--- src/core/hle/service/am/applets/applets.h | 6 +++--- src/core/hle/service/bcat/backend/backend.cpp | 2 +- src/core/hle/service/bcat/module.cpp | 2 +- src/core/hle/service/hid/controllers/npad.cpp | 3 +-- src/core/hle/service/hid/controllers/npad.h | 2 +- src/core/hle/service/hid/hid.cpp | 2 +- src/core/hle/service/hid/irs.cpp | 2 +- src/core/hle/service/nfp/nfp.cpp | 2 +- src/core/hle/service/nfp/nfp.h | 2 +- src/core/hle/service/ns/pl_u.cpp | 2 +- src/core/hle/service/nvdrv/interface.cpp | 2 +- src/core/hle/service/nvdrv/nvdrv.cpp | 2 +- src/core/hle/service/nvflinger/buffer_queue.cpp | 2 +- src/core/hle/service/nvflinger/buffer_queue.h | 1 + src/core/hle/service/sm/controller.cpp | 2 +- src/core/hle/service/sm/sm.cpp | 8 +++++--- src/core/hle/service/time/time.cpp | 2 +- src/core/hle/service/vi/display/vi_display.cpp | 2 +- src/core/hle/service/vi/vi.cpp | 4 ++-- 22 files changed, 33 insertions(+), 32 deletions(-) (limited to 'src/core/hle/service') diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 58c7f2930..7be94446a 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -588,12 +588,11 @@ AppletMessageQueue::AppletMessageQueue(Kernel::KernelCore& kernel) { AppletMessageQueue::~AppletMessageQueue() = default; -const std::shared_ptr& AppletMessageQueue::GetMessageReceiveEvent() const { +Kernel::KReadableEvent* AppletMessageQueue::GetMessageReceiveEvent() const { return on_new_message->GetReadableEvent(); } -const std::shared_ptr& AppletMessageQueue::GetOperationModeChangedEvent() - const { +Kernel::KReadableEvent* AppletMessageQueue::GetOperationModeChangedEvent() const { return on_operation_mode_changed->GetReadableEvent(); } diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index 5d302e155..f8daeb437 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -56,8 +56,8 @@ public: explicit AppletMessageQueue(Kernel::KernelCore& kernel); ~AppletMessageQueue(); - const std::shared_ptr& GetMessageReceiveEvent() const; - const std::shared_ptr& GetOperationModeChangedEvent() const; + Kernel::KReadableEvent* GetMessageReceiveEvent() const; + Kernel::KReadableEvent* GetOperationModeChangedEvent() const; void PushMessage(AppletMessage msg); AppletMessage PopMessage(); std::size_t GetMessageCount() const; diff --git a/src/core/hle/service/am/applets/applets.cpp b/src/core/hle/service/am/applets/applets.cpp index a56df6a7e..c093813fe 100644 --- a/src/core/hle/service/am/applets/applets.cpp +++ b/src/core/hle/service/am/applets/applets.cpp @@ -142,15 +142,15 @@ void AppletDataBroker::SignalStateChanged() const { } } -std::shared_ptr AppletDataBroker::GetNormalDataEvent() const { +Kernel::KReadableEvent* AppletDataBroker::GetNormalDataEvent() const { return pop_out_data_event->GetReadableEvent(); } -std::shared_ptr AppletDataBroker::GetInteractiveDataEvent() const { +Kernel::KReadableEvent* AppletDataBroker::GetInteractiveDataEvent() const { return pop_interactive_out_data_event->GetReadableEvent(); } -std::shared_ptr AppletDataBroker::GetStateChangedEvent() const { +Kernel::KReadableEvent* AppletDataBroker::GetStateChangedEvent() const { return state_changed_event->GetReadableEvent(); } diff --git a/src/core/hle/service/am/applets/applets.h b/src/core/hle/service/am/applets/applets.h index 4215d2232..ffde8ced0 100644 --- a/src/core/hle/service/am/applets/applets.h +++ b/src/core/hle/service/am/applets/applets.h @@ -97,9 +97,9 @@ public: void SignalStateChanged() const; - std::shared_ptr GetNormalDataEvent() const; - std::shared_ptr GetInteractiveDataEvent() const; - std::shared_ptr GetStateChangedEvent() const; + Kernel::KReadableEvent* GetNormalDataEvent() const; + Kernel::KReadableEvent* GetInteractiveDataEvent() const; + Kernel::KReadableEvent* GetStateChangedEvent() const; private: Core::System& system; diff --git a/src/core/hle/service/bcat/backend/backend.cpp b/src/core/hle/service/bcat/backend/backend.cpp index 92d25dbe4..7f301fdeb 100644 --- a/src/core/hle/service/bcat/backend/backend.cpp +++ b/src/core/hle/service/bcat/backend/backend.cpp @@ -21,7 +21,7 @@ ProgressServiceBackend::ProgressServiceBackend(Kernel::KernelCore& kernel, } std::shared_ptr ProgressServiceBackend::GetEvent() const { - return event->GetReadableEvent(); + return SharedFrom(event->GetReadableEvent()); } DeliveryCacheProgressImpl& ProgressServiceBackend::GetImpl() { diff --git a/src/core/hle/service/bcat/module.cpp b/src/core/hle/service/bcat/module.cpp index 285085f2a..8473b716b 100644 --- a/src/core/hle/service/bcat/module.cpp +++ b/src/core/hle/service/bcat/module.cpp @@ -109,7 +109,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(event); + rb.PushCopyObjects(event.get()); } void GetImpl(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index d4678ef49..9d07ca09c 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp @@ -955,8 +955,7 @@ bool Controller_NPad::IsVibrationDeviceMounted(const DeviceHandle& vibration_dev return vibration_devices_mounted[npad_index][device_index]; } -std::shared_ptr Controller_NPad::GetStyleSetChangedEvent( - u32 npad_id) const { +Kernel::KReadableEvent* Controller_NPad::GetStyleSetChangedEvent(u32 npad_id) const { const auto& styleset_event = styleset_changed_events[NPadIdToIndex(npad_id)]; return styleset_event->GetReadableEvent(); } diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index ea484d4bf..8c24728b1 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h @@ -199,7 +199,7 @@ public: bool IsVibrationDeviceMounted(const DeviceHandle& vibration_device_handle) const; - std::shared_ptr GetStyleSetChangedEvent(u32 npad_id) const; + Kernel::KReadableEvent* GetStyleSetChangedEvent(u32 npad_id) const; void SignalStyleSetChangedEvent(u32 npad_id) const; // Adds a new controller at an index. diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 9c4bf6d16..d2a6375f5 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -118,7 +118,7 @@ void IAppletResource::GetSharedMemoryHandle(Kernel::HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(shared_mem); + rb.PushCopyObjects(shared_mem.get()); } void IAppletResource::UpdateControllers(std::uintptr_t user_data, diff --git a/src/core/hle/service/hid/irs.cpp b/src/core/hle/service/hid/irs.cpp index 2dfa936fb..b50a51eb7 100644 --- a/src/core/hle/service/hid/irs.cpp +++ b/src/core/hle/service/hid/irs.cpp @@ -62,7 +62,7 @@ void IRS::GetIrsensorSharedMemoryHandle(Kernel::HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(shared_mem); + rb.PushCopyObjects(shared_mem.get()); } void IRS::StopImageProcessor(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/nfp/nfp.cpp b/src/core/hle/service/nfp/nfp.cpp index 2d1d4d67f..1446c0bcf 100644 --- a/src/core/hle/service/nfp/nfp.cpp +++ b/src/core/hle/service/nfp/nfp.cpp @@ -343,7 +343,7 @@ bool Module::Interface::LoadAmiibo(const std::vector& buffer) { return true; } -const std::shared_ptr& Module::Interface::GetNFCEvent() const { +Kernel::KReadableEvent* Module::Interface::GetNFCEvent() const { return nfc_tag_load->GetReadableEvent(); } diff --git a/src/core/hle/service/nfp/nfp.h b/src/core/hle/service/nfp/nfp.h index c46551760..7a97caffb 100644 --- a/src/core/hle/service/nfp/nfp.h +++ b/src/core/hle/service/nfp/nfp.h @@ -38,7 +38,7 @@ public: void CreateUserInterface(Kernel::HLERequestContext& ctx); bool LoadAmiibo(const std::vector& buffer); - const std::shared_ptr& GetNFCEvent() const; + Kernel::KReadableEvent* GetNFCEvent() const; const AmiiboFile& GetAmiiboBuffer() const; private: diff --git a/src/core/hle/service/ns/pl_u.cpp b/src/core/hle/service/ns/pl_u.cpp index da139fdc4..e6616a3b9 100644 --- a/src/core/hle/service/ns/pl_u.cpp +++ b/src/core/hle/service/ns/pl_u.cpp @@ -267,7 +267,7 @@ void PL_U::GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(impl->shared_font_mem); + rb.PushCopyObjects(impl->shared_font_mem.get()); } void PL_U::GetSharedFontInOrderOfPriority(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/nvdrv/interface.cpp b/src/core/hle/service/nvdrv/interface.cpp index eff9c3cc9..8e359040f 100644 --- a/src/core/hle/service/nvdrv/interface.cpp +++ b/src/core/hle/service/nvdrv/interface.cpp @@ -189,7 +189,7 @@ void NVDRV::QueryEvent(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); auto event = nvdrv->GetEvent(event_id); event->Clear(); - rb.PushCopyObjects(event); + rb.PushCopyObjects(event.get()); rb.PushEnum(NvResult::Success); } else { IPC::ResponseBuilder rb{ctx, 3}; diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp index ede77858a..6bba9c0b3 100644 --- a/src/core/hle/service/nvdrv/nvdrv.cpp +++ b/src/core/hle/service/nvdrv/nvdrv.cpp @@ -178,7 +178,7 @@ void Module::SignalSyncpt(const u32 syncpoint_id, const u32 value) { } std::shared_ptr Module::GetEvent(const u32 event_id) const { - return events_interface.events[event_id].event->GetReadableEvent(); + return SharedFrom(events_interface.events[event_id].event->GetReadableEvent()); } std::shared_ptr Module::GetEventWriteable(const u32 event_id) const { diff --git a/src/core/hle/service/nvflinger/buffer_queue.cpp b/src/core/hle/service/nvflinger/buffer_queue.cpp index 7842a82ed..f783ae54f 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.cpp +++ b/src/core/hle/service/nvflinger/buffer_queue.cpp @@ -194,7 +194,7 @@ std::shared_ptr BufferQueue::GetWritableBufferWaitEvent( } std::shared_ptr BufferQueue::GetBufferWaitEvent() const { - return buffer_wait_event->GetReadableEvent(); + return SharedFrom(buffer_wait_event->GetReadableEvent()); } } // namespace Service::NVFlinger diff --git a/src/core/hle/service/nvflinger/buffer_queue.h b/src/core/hle/service/nvflinger/buffer_queue.h index 163fa4c54..9a21c7426 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.h +++ b/src/core/hle/service/nvflinger/buffer_queue.h @@ -13,6 +13,7 @@ #include "common/common_funcs.h" #include "common/math_util.h" #include "common/swap.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/object.h" #include "core/hle/service/nvdrv/nvdata.h" diff --git a/src/core/hle/service/sm/controller.cpp b/src/core/hle/service/sm/controller.cpp index 916177efd..b34fe4bc2 100644 --- a/src/core/hle/service/sm/controller.cpp +++ b/src/core/hle/service/sm/controller.cpp @@ -30,7 +30,7 @@ void Controller::CloneCurrentObject(Kernel::HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles}; rb.Push(RESULT_SUCCESS); - rb.PushMoveObjects(ctx.Session()->GetParent()->Client()); + rb.PushMoveObjects(ctx.Session()->GetParent()->Client().get()); } void Controller::CloneCurrentObjectEx(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index 94608d529..62f7a5358 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp @@ -134,7 +134,7 @@ void SM::GetService(Kernel::HLERequestContext& ctx) { const auto& server_port = client_port.Unwrap()->GetServerPort(); if (server_port->GetHLEHandler()) { - server_port->GetHLEHandler()->ClientConnected(server); + server_port->GetHLEHandler()->ClientConnected(client, server); } else { server_port->AppendPendingSession(server); } @@ -142,7 +142,7 @@ void SM::GetService(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_SM, "called service={} -> session={}", name, client->GetObjectId()); IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles}; rb.Push(RESULT_SUCCESS); - rb.PushMoveObjects(std::move(client)); + rb.PushMoveObjects(client.get()); } void SM::RegisterService(Kernel::HLERequestContext& ctx) { @@ -170,7 +170,9 @@ void SM::RegisterService(Kernel::HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles}; rb.Push(handle.Code()); - rb.PushMoveObjects(std::move(handle).Unwrap()); + + auto server_port = handle.Unwrap(); + rb.PushMoveObjects(server_port.get()); } void SM::UnregisterService(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index 32f372d71..30283f239 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp @@ -393,7 +393,7 @@ void Module::Interface::GetSharedMemoryNativeHandle(Kernel::HLERequestContext& c LOG_DEBUG(Service_Time, "called"); IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(SharedFrom(&system.Kernel().GetTimeSharedMem())); + rb.PushCopyObjects(&system.Kernel().GetTimeSharedMem()); } Module::Interface::Interface(std::shared_ptr module_, Core::System& system_, diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp index ac9e87338..9ffa71352 100644 --- a/src/core/hle/service/vi/display/vi_display.cpp +++ b/src/core/hle/service/vi/display/vi_display.cpp @@ -34,7 +34,7 @@ const Layer& Display::GetLayer(std::size_t index) const { } std::shared_ptr Display::GetVSyncEvent() const { - return vsync_event->GetReadableEvent(); + return SharedFrom(vsync_event->GetReadableEvent()); } void Display::SignalVSyncEvent() { diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 7ae07d072..6e507bfb8 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -674,7 +674,7 @@ private: // TODO(Subv): Find out what this actually is. IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(buffer_queue.GetBufferWaitEvent()); + rb.PushCopyObjects(buffer_queue.GetBufferWaitEvent().get()); } NVFlinger::NVFlinger& nv_flinger; @@ -1209,7 +1209,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(vsync_event); + rb.PushCopyObjects(vsync_event.get()); } void ConvertScalingMode(Kernel::HLERequestContext& ctx) { -- cgit v1.2.3