summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/service')
-rw-r--r--src/core/hle/service/acc/acc.cpp2
-rw-r--r--src/core/hle/service/am/am.cpp115
-rw-r--r--src/core/hle/service/am/am.h24
-rw-r--r--src/core/hle/service/am/applets/applets.cpp46
-rw-r--r--src/core/hle/service/am/applets/applets.h16
-rw-r--r--src/core/hle/service/am/applets/error.cpp2
-rw-r--r--src/core/hle/service/am/applets/general_backend.cpp2
-rw-r--r--src/core/hle/service/am/applets/web_browser.cpp2
-rw-r--r--src/core/hle/service/aoc/aoc_u.cpp24
-rw-r--r--src/core/hle/service/aoc/aoc_u.h3
-rw-r--r--src/core/hle/service/audio/audout_u.cpp16
-rw-r--r--src/core/hle/service/audio/audren_u.cpp45
-rw-r--r--src/core/hle/service/bcat/backend/backend.cpp19
-rw-r--r--src/core/hle/service/bcat/backend/backend.h7
-rw-r--r--src/core/hle/service/bcat/module.cpp10
-rw-r--r--src/core/hle/service/btdrv/btdrv.cpp12
-rw-r--r--src/core/hle/service/btm/btm.cpp39
-rw-r--r--src/core/hle/service/fatal/fatal.cpp2
-rw-r--r--src/core/hle/service/filesystem/filesystem.cpp2
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.cpp2
-rw-r--r--src/core/hle/service/friend/friend.cpp12
-rw-r--r--src/core/hle/service/glue/arp.cpp2
-rw-r--r--src/core/hle/service/hid/controllers/npad.cpp20
-rw-r--r--src/core/hle/service/hid/controllers/npad.h8
-rw-r--r--src/core/hle/service/hid/hid.cpp30
-rw-r--r--src/core/hle/service/hid/hid.h6
-rw-r--r--src/core/hle/service/hid/irs.cpp6
-rw-r--r--src/core/hle/service/hid/irs.h6
-rw-r--r--src/core/hle/service/ldr/ldr.cpp8
-rw-r--r--src/core/hle/service/mm/mm_u.cpp1
-rw-r--r--src/core/hle/service/nfp/nfp.cpp39
-rw-r--r--src/core/hle/service/nfp/nfp.h5
-rw-r--r--src/core/hle/service/nifm/nifm.cpp16
-rw-r--r--src/core/hle/service/nim/nim.cpp17
-rw-r--r--src/core/hle/service/ns/pl_u.cpp8
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp8
-rw-r--r--src/core/hle/service/nvdrv/interface.cpp4
-rw-r--r--src/core/hle/service/nvdrv/nvdrv.cpp18
-rw-r--r--src/core/hle/service/nvdrv/nvdrv.h6
-rw-r--r--src/core/hle/service/nvflinger/buffer_queue.cpp23
-rw-r--r--src/core/hle/service/nvflinger/buffer_queue.h9
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.cpp4
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.h6
-rw-r--r--src/core/hle/service/pctl/module.cpp2
-rw-r--r--src/core/hle/service/pm/pm.cpp17
-rw-r--r--src/core/hle/service/prepo/prepo.cpp10
-rw-r--r--src/core/hle/service/ptm/psm.cpp18
-rw-r--r--src/core/hle/service/service.cpp15
-rw-r--r--src/core/hle/service/service.h6
-rw-r--r--src/core/hle/service/set/set_sys.cpp2
-rw-r--r--src/core/hle/service/sm/controller.cpp10
-rw-r--r--src/core/hle/service/sm/sm.cpp63
-rw-r--r--src/core/hle/service/sm/sm.h25
-rw-r--r--src/core/hle/service/time/standard_user_system_clock_core.cpp9
-rw-r--r--src/core/hle/service/time/standard_user_system_clock_core.h3
-rw-r--r--src/core/hle/service/time/time.cpp5
-rw-r--r--src/core/hle/service/time/time_sharedmemory.cpp15
-rw-r--r--src/core/hle/service/time/time_sharedmemory.h4
-rw-r--r--src/core/hle/service/vi/display/vi_display.cpp14
-rw-r--r--src/core/hle/service/vi/display/vi_display.h14
-rw-r--r--src/core/hle/service/vi/vi.cpp4
61 files changed, 426 insertions, 462 deletions
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp
index 5450dcf0f..49c09a570 100644
--- a/src/core/hle/service/acc/acc.cpp
+++ b/src/core/hle/service/acc/acc.cpp
@@ -16,8 +16,8 @@
#include "core/file_sys/control_metadata.h"
#include "core/file_sys/patch_manager.h"
#include "core/hle/ipc_helpers.h"
+#include "core/hle/kernel/k_process.h"
#include "core/hle/kernel/kernel.h"
-#include "core/hle/kernel/process.h"
#include "core/hle/service/acc/acc.h"
#include "core/hle/service/acc/acc_aa.h"
#include "core/hle/service/acc/acc_su.h"
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index 58c7f2930..408e441dc 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -15,11 +15,11 @@
#include "core/file_sys/savedata_factory.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/kernel/k_event.h"
+#include "core/hle/kernel/k_process.h"
#include "core/hle/kernel/k_readable_event.h"
+#include "core/hle/kernel/k_transfer_memory.h"
#include "core/hle/kernel/k_writable_event.h"
#include "core/hle/kernel/kernel.h"
-#include "core/hle/kernel/process.h"
-#include "core/hle/kernel/transfer_memory.h"
#include "core/hle/service/acc/profile_manager.h"
#include "core/hle/service/am/am.h"
#include "core/hle/service/am/applet_ae.h"
@@ -42,6 +42,7 @@
#include "core/hle/service/set/set.h"
#include "core/hle/service/sm/sm.h"
#include "core/hle/service/vi/vi.h"
+#include "core/memory.h"
namespace Service::AM {
@@ -253,7 +254,8 @@ IDebugFunctions::IDebugFunctions(Core::System& system_)
IDebugFunctions::~IDebugFunctions() = default;
ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nvflinger_)
- : ServiceFramework{system_, "ISelfController"}, nvflinger{nvflinger_} {
+ : ServiceFramework{system_, "ISelfController"}, nvflinger{nvflinger_},
+ launchable_event{system.Kernel()}, accumulated_suspended_tick_changed_event{system.Kernel()} {
// clang-format off
static const FunctionInfo functions[] = {
{0, &ISelfController::Exit, "Exit"},
@@ -306,19 +308,20 @@ ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nv
RegisterHandlers(functions);
- auto& kernel = system.Kernel();
- launchable_event = Kernel::KEvent::Create(kernel, "ISelfController:LaunchableEvent");
- launchable_event->Initialize();
+ Kernel::KAutoObject::Create(std::addressof(launchable_event));
+
+ launchable_event.Initialize("ISelfController:LaunchableEvent");
// This event is created by AM on the first time GetAccumulatedSuspendedTickChangedEvent() is
// called. Yuzu can just create it unconditionally, since it doesn't need to support multiple
// ISelfControllers. The event is signaled on creation, and on transition from suspended -> not
// suspended if the event has previously been created by a call to
// GetAccumulatedSuspendedTickChangedEvent.
- accumulated_suspended_tick_changed_event =
- Kernel::KEvent::Create(kernel, "ISelfController:AccumulatedSuspendedTickChangedEvent");
- accumulated_suspended_tick_changed_event->Initialize();
- accumulated_suspended_tick_changed_event->GetWritableEvent()->Signal();
+
+ Kernel::KAutoObject::Create(std::addressof(accumulated_suspended_tick_changed_event));
+ accumulated_suspended_tick_changed_event.Initialize(
+ "ISelfController:AccumulatedSuspendedTickChangedEvent");
+ accumulated_suspended_tick_changed_event.GetWritableEvent().Signal();
}
ISelfController::~ISelfController() = default;
@@ -377,11 +380,11 @@ void ISelfController::LeaveFatalSection(Kernel::HLERequestContext& ctx) {
void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");
- launchable_event->GetWritableEvent()->Signal();
+ launchable_event.GetWritableEvent().Signal();
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(launchable_event->GetReadableEvent());
+ rb.PushCopyObjects(launchable_event.GetReadableEvent());
}
void ISelfController::SetScreenShotPermission(Kernel::HLERequestContext& ctx) {
@@ -560,7 +563,7 @@ void ISelfController::GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequest
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(accumulated_suspended_tick_changed_event->GetReadableEvent());
+ rb.PushCopyObjects(accumulated_suspended_tick_changed_event.GetReadableEvent());
}
void ISelfController::SetAlbumImageTakenNotificationEnabled(Kernel::HLERequestContext& ctx) {
@@ -578,39 +581,40 @@ void ISelfController::SetAlbumImageTakenNotificationEnabled(Kernel::HLERequestCo
rb.Push(RESULT_SUCCESS);
}
-AppletMessageQueue::AppletMessageQueue(Kernel::KernelCore& kernel) {
- on_new_message = Kernel::KEvent::Create(kernel, "AMMessageQueue:OnMessageReceived");
- on_new_message->Initialize();
- on_operation_mode_changed =
- Kernel::KEvent::Create(kernel, "AMMessageQueue:OperationModeChanged");
- on_operation_mode_changed->Initialize();
+AppletMessageQueue::AppletMessageQueue(Kernel::KernelCore& kernel)
+ : on_new_message{kernel}, on_operation_mode_changed{kernel} {
+
+ Kernel::KAutoObject::Create(std::addressof(on_new_message));
+ Kernel::KAutoObject::Create(std::addressof(on_operation_mode_changed));
+
+ on_new_message.Initialize("AMMessageQueue:OnMessageReceived");
+ on_operation_mode_changed.Initialize("AMMessageQueue:OperationModeChanged");
}
AppletMessageQueue::~AppletMessageQueue() = default;
-const std::shared_ptr<Kernel::KReadableEvent>& AppletMessageQueue::GetMessageReceiveEvent() const {
- return on_new_message->GetReadableEvent();
+Kernel::KReadableEvent& AppletMessageQueue::GetMessageReceiveEvent() {
+ return on_new_message.GetReadableEvent();
}
-const std::shared_ptr<Kernel::KReadableEvent>& AppletMessageQueue::GetOperationModeChangedEvent()
- const {
- return on_operation_mode_changed->GetReadableEvent();
+Kernel::KReadableEvent& AppletMessageQueue::GetOperationModeChangedEvent() {
+ return on_operation_mode_changed.GetReadableEvent();
}
void AppletMessageQueue::PushMessage(AppletMessage msg) {
messages.push(msg);
- on_new_message->GetWritableEvent()->Signal();
+ on_new_message.GetWritableEvent().Signal();
}
AppletMessageQueue::AppletMessage AppletMessageQueue::PopMessage() {
if (messages.empty()) {
- on_new_message->GetWritableEvent()->Clear();
+ on_new_message.GetWritableEvent().Clear();
return AppletMessage::NoMessage;
}
auto msg = messages.front();
messages.pop();
if (messages.empty()) {
- on_new_message->GetWritableEvent()->Clear();
+ on_new_message.GetWritableEvent().Clear();
}
return msg;
}
@@ -630,7 +634,7 @@ void AppletMessageQueue::FocusStateChanged() {
void AppletMessageQueue::OperationModeChanged() {
PushMessage(AppletMessage::OperationModeChanged);
PushMessage(AppletMessage::PerformanceModeChanged);
- on_operation_mode_changed->GetWritableEvent()->Signal();
+ on_operation_mode_changed.GetWritableEvent().Signal();
}
ICommonStateGetter::ICommonStateGetter(Core::System& system_,
@@ -927,11 +931,9 @@ private:
void GetAppletStateChangedEvent(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_AM, "called");
- const auto event = applet->GetBroker().GetStateChangedEvent();
-
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(event);
+ rb.PushCopyObjects(applet->GetBroker().GetStateChangedEvent());
}
void IsCompleted(Kernel::HLERequestContext& ctx) {
@@ -1213,16 +1215,16 @@ void ILibraryAppletCreator::CreateTransferMemoryStorage(Kernel::HLERequestContex
}
auto transfer_mem =
- system.CurrentProcess()->GetHandleTable().Get<Kernel::TransferMemory>(handle);
+ system.CurrentProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(handle);
- if (transfer_mem == nullptr) {
+ if (transfer_mem.IsNull()) {
LOG_ERROR(Service_AM, "transfer_mem is a nullptr for handle={:08X}", handle);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_UNKNOWN);
return;
}
- const u8* const mem_begin = transfer_mem->GetPointer();
+ const u8* const mem_begin = system.Memory().GetPointer(transfer_mem->GetSourceAddress());
const u8* const mem_end = mem_begin + transfer_mem->GetSize();
std::vector<u8> memory{mem_begin, mem_end};
@@ -1247,16 +1249,16 @@ void ILibraryAppletCreator::CreateHandleStorage(Kernel::HLERequestContext& ctx)
}
auto transfer_mem =
- system.CurrentProcess()->GetHandleTable().Get<Kernel::TransferMemory>(handle);
+ system.CurrentProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(handle);
- if (transfer_mem == nullptr) {
+ if (transfer_mem.IsNull()) {
LOG_ERROR(Service_AM, "transfer_mem is a nullptr for handle={:08X}", handle);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_UNKNOWN);
return;
}
- const u8* const mem_begin = transfer_mem->GetPointer();
+ const u8* const mem_begin = system.Memory().GetPointer(transfer_mem->GetSourceAddress());
const u8* const mem_end = mem_begin + transfer_mem->GetSize();
std::vector<u8> memory{mem_begin, mem_end};
@@ -1266,7 +1268,9 @@ void ILibraryAppletCreator::CreateHandleStorage(Kernel::HLERequestContext& ctx)
}
IApplicationFunctions::IApplicationFunctions(Core::System& system_)
- : ServiceFramework{system_, "IApplicationFunctions"} {
+ : ServiceFramework{system_, "IApplicationFunctions"}, gpu_error_detected_event{system.Kernel()},
+ friend_invitation_storage_channel_event{system.Kernel()},
+ health_warning_disappeared_system_event{system.Kernel()} {
// clang-format off
static const FunctionInfo functions[] = {
{1, &IApplicationFunctions::PopLaunchParameter, "PopLaunchParameter"},
@@ -1334,16 +1338,15 @@ IApplicationFunctions::IApplicationFunctions(Core::System& system_)
RegisterHandlers(functions);
- auto& kernel = system.Kernel();
- gpu_error_detected_event =
- Kernel::KEvent::Create(kernel, "IApplicationFunctions:GpuErrorDetectedSystemEvent");
- gpu_error_detected_event->Initialize();
- friend_invitation_storage_channel_event =
- Kernel::KEvent::Create(kernel, "IApplicationFunctions:FriendInvitationStorageChannelEvent");
- friend_invitation_storage_channel_event->Initialize();
- health_warning_disappeared_system_event =
- Kernel::KEvent::Create(kernel, "IApplicationFunctions:HealthWarningDisappearedSystemEvent");
- health_warning_disappeared_system_event->Initialize();
+ Kernel::KAutoObject::Create(std::addressof(gpu_error_detected_event));
+ Kernel::KAutoObject::Create(std::addressof(friend_invitation_storage_channel_event));
+ Kernel::KAutoObject::Create(std::addressof(health_warning_disappeared_system_event));
+
+ gpu_error_detected_event.Initialize("IApplicationFunctions:GpuErrorDetectedSystemEvent");
+ friend_invitation_storage_channel_event.Initialize(
+ "IApplicationFunctions:FriendInvitationStorageChannelEvent");
+ health_warning_disappeared_system_event.Initialize(
+ "IApplicationFunctions:HealthWarningDisappearedSystemEvent");
}
IApplicationFunctions::~IApplicationFunctions() = default;
@@ -1740,7 +1743,7 @@ void IApplicationFunctions::GetGpuErrorDetectedSystemEvent(Kernel::HLERequestCon
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(gpu_error_detected_event->GetReadableEvent());
+ rb.PushCopyObjects(gpu_error_detected_event.GetReadableEvent());
}
void IApplicationFunctions::GetFriendInvitationStorageChannelEvent(Kernel::HLERequestContext& ctx) {
@@ -1748,7 +1751,7 @@ void IApplicationFunctions::GetFriendInvitationStorageChannelEvent(Kernel::HLERe
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(friend_invitation_storage_channel_event->GetReadableEvent());
+ rb.PushCopyObjects(friend_invitation_storage_channel_event.GetReadableEvent());
}
void IApplicationFunctions::TryPopFromFriendInvitationStorageChannel(
@@ -1764,7 +1767,7 @@ void IApplicationFunctions::GetHealthWarningDisappearedSystemEvent(Kernel::HLERe
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(health_warning_disappeared_system_event->GetReadableEvent());
+ rb.PushCopyObjects(health_warning_disappeared_system_event.GetReadableEvent());
}
void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger,
@@ -1782,7 +1785,8 @@ void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger
}
IHomeMenuFunctions::IHomeMenuFunctions(Core::System& system_)
- : ServiceFramework{system_, "IHomeMenuFunctions"} {
+ : ServiceFramework{system_, "IHomeMenuFunctions"}, pop_from_general_channel_event{
+ system.Kernel()} {
// clang-format off
static const FunctionInfo functions[] = {
{10, &IHomeMenuFunctions::RequestToGetForeground, "RequestToGetForeground"},
@@ -1803,9 +1807,8 @@ IHomeMenuFunctions::IHomeMenuFunctions(Core::System& system_)
RegisterHandlers(functions);
- pop_from_general_channel_event =
- Kernel::KEvent::Create(system.Kernel(), "IHomeMenuFunctions:PopFromGeneralChannelEvent");
- pop_from_general_channel_event->Initialize();
+ Kernel::KAutoObject::Create(std::addressof(pop_from_general_channel_event));
+ pop_from_general_channel_event.Initialize("IHomeMenuFunctions:PopFromGeneralChannelEvent");
}
IHomeMenuFunctions::~IHomeMenuFunctions() = default;
@@ -1822,7 +1825,7 @@ void IHomeMenuFunctions::GetPopFromGeneralChannelEvent(Kernel::HLERequestContext
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(pop_from_general_channel_event->GetReadableEvent());
+ rb.PushCopyObjects(pop_from_general_channel_event.GetReadableEvent());
}
IGlobalStateController::IGlobalStateController(Core::System& system_)
diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h
index 5d302e155..184030a8e 100644
--- a/src/core/hle/service/am/am.h
+++ b/src/core/hle/service/am/am.h
@@ -8,12 +8,12 @@
#include <memory>
#include <queue>
+#include "core/hle/kernel/k_event.h"
#include "core/hle/service/service.h"
namespace Kernel {
class KernelCore;
-class KEvent;
-class TransferMemory;
+class KTransferMemory;
} // namespace Kernel
namespace Service::NVFlinger {
@@ -56,8 +56,8 @@ public:
explicit AppletMessageQueue(Kernel::KernelCore& kernel);
~AppletMessageQueue();
- const std::shared_ptr<Kernel::KReadableEvent>& GetMessageReceiveEvent() const;
- const std::shared_ptr<Kernel::KReadableEvent>& GetOperationModeChangedEvent() const;
+ Kernel::KReadableEvent& GetMessageReceiveEvent();
+ Kernel::KReadableEvent& GetOperationModeChangedEvent();
void PushMessage(AppletMessage msg);
AppletMessage PopMessage();
std::size_t GetMessageCount() const;
@@ -67,8 +67,8 @@ public:
private:
std::queue<AppletMessage> messages;
- std::shared_ptr<Kernel::KEvent> on_new_message;
- std::shared_ptr<Kernel::KEvent> on_operation_mode_changed;
+ Kernel::KEvent on_new_message;
+ Kernel::KEvent on_operation_mode_changed;
};
class IWindowController final : public ServiceFramework<IWindowController> {
@@ -156,8 +156,8 @@ private:
};
NVFlinger::NVFlinger& nvflinger;
- std::shared_ptr<Kernel::KEvent> launchable_event;
- std::shared_ptr<Kernel::KEvent> accumulated_suspended_tick_changed_event;
+ Kernel::KEvent launchable_event;
+ Kernel::KEvent accumulated_suspended_tick_changed_event;
u32 idle_time_detection_extension = 0;
u64 num_fatal_sections_entered = 0;
@@ -300,9 +300,9 @@ private:
bool launch_popped_application_specific = false;
bool launch_popped_account_preselect = false;
s32 previous_program_index{-1};
- std::shared_ptr<Kernel::KEvent> gpu_error_detected_event;
- std::shared_ptr<Kernel::KEvent> friend_invitation_storage_channel_event;
- std::shared_ptr<Kernel::KEvent> health_warning_disappeared_system_event;
+ Kernel::KEvent gpu_error_detected_event;
+ Kernel::KEvent friend_invitation_storage_channel_event;
+ Kernel::KEvent health_warning_disappeared_system_event;
};
class IHomeMenuFunctions final : public ServiceFramework<IHomeMenuFunctions> {
@@ -314,7 +314,7 @@ private:
void RequestToGetForeground(Kernel::HLERequestContext& ctx);
void GetPopFromGeneralChannelEvent(Kernel::HLERequestContext& ctx);
- std::shared_ptr<Kernel::KEvent> pop_from_general_channel_event;
+ Kernel::KEvent pop_from_general_channel_event;
};
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 a56df6a7e..ae995df6b 100644
--- a/src/core/hle/service/am/applets/applets.cpp
+++ b/src/core/hle/service/am/applets/applets.cpp
@@ -12,10 +12,8 @@
#include "core/frontend/applets/profile_select.h"
#include "core/frontend/applets/software_keyboard.h"
#include "core/frontend/applets/web_browser.h"
-#include "core/hle/kernel/k_event.h"
#include "core/hle/kernel/k_readable_event.h"
#include "core/hle/kernel/k_writable_event.h"
-#include "core/hle/kernel/server_session.h"
#include "core/hle/service/am/am.h"
#include "core/hle/service/am/applet_ae.h"
#include "core/hle/service/am/applet_oe.h"
@@ -31,16 +29,16 @@
namespace Service::AM::Applets {
AppletDataBroker::AppletDataBroker(Core::System& system_, LibraryAppletMode applet_mode_)
- : system{system_}, applet_mode{applet_mode_} {
- state_changed_event =
- Kernel::KEvent::Create(system.Kernel(), "ILibraryAppletAccessor:StateChangedEvent");
- state_changed_event->Initialize();
- pop_out_data_event =
- Kernel::KEvent::Create(system.Kernel(), "ILibraryAppletAccessor:PopDataOutEvent");
- pop_out_data_event->Initialize();
- pop_interactive_out_data_event = Kernel::KEvent::Create(
- system.Kernel(), "ILibraryAppletAccessor:PopInteractiveDataOutEvent");
- pop_interactive_out_data_event->Initialize();
+ : system{system_}, applet_mode{applet_mode_}, state_changed_event{system.Kernel()},
+ pop_out_data_event{system.Kernel()}, pop_interactive_out_data_event{system.Kernel()} {
+
+ Kernel::KAutoObject::Create(std::addressof(state_changed_event));
+ Kernel::KAutoObject::Create(std::addressof(pop_out_data_event));
+ Kernel::KAutoObject::Create(std::addressof(pop_interactive_out_data_event));
+
+ state_changed_event.Initialize("ILibraryAppletAccessor:StateChangedEvent");
+ pop_out_data_event.Initialize("ILibraryAppletAccessor:PopDataOutEvent");
+ pop_interactive_out_data_event.Initialize("ILibraryAppletAccessor:PopInteractiveDataOutEvent");
}
AppletDataBroker::~AppletDataBroker() = default;
@@ -67,7 +65,7 @@ std::shared_ptr<IStorage> AppletDataBroker::PopNormalDataToGame() {
auto out = std::move(out_channel.front());
out_channel.pop_front();
- pop_out_data_event->GetWritableEvent()->Clear();
+ pop_out_data_event.GetWritableEvent().Clear();
return out;
}
@@ -86,7 +84,7 @@ std::shared_ptr<IStorage> AppletDataBroker::PopInteractiveDataToGame() {
auto out = std::move(out_interactive_channel.front());
out_interactive_channel.pop_front();
- pop_interactive_out_data_event->GetWritableEvent()->Clear();
+ pop_interactive_out_data_event.GetWritableEvent().Clear();
return out;
}
@@ -105,7 +103,7 @@ void AppletDataBroker::PushNormalDataFromGame(std::shared_ptr<IStorage>&& storag
void AppletDataBroker::PushNormalDataFromApplet(std::shared_ptr<IStorage>&& storage) {
out_channel.emplace_back(std::move(storage));
- pop_out_data_event->GetWritableEvent()->Signal();
+ pop_out_data_event.GetWritableEvent().Signal();
}
void AppletDataBroker::PushInteractiveDataFromGame(std::shared_ptr<IStorage>&& storage) {
@@ -114,11 +112,11 @@ void AppletDataBroker::PushInteractiveDataFromGame(std::shared_ptr<IStorage>&& s
void AppletDataBroker::PushInteractiveDataFromApplet(std::shared_ptr<IStorage>&& storage) {
out_interactive_channel.emplace_back(std::move(storage));
- pop_interactive_out_data_event->GetWritableEvent()->Signal();
+ pop_interactive_out_data_event.GetWritableEvent().Signal();
}
-void AppletDataBroker::SignalStateChanged() const {
- state_changed_event->GetWritableEvent()->Signal();
+void AppletDataBroker::SignalStateChanged() {
+ state_changed_event.GetWritableEvent().Signal();
switch (applet_mode) {
case LibraryAppletMode::AllForeground:
@@ -142,16 +140,16 @@ void AppletDataBroker::SignalStateChanged() const {
}
}
-std::shared_ptr<Kernel::KReadableEvent> AppletDataBroker::GetNormalDataEvent() const {
- return pop_out_data_event->GetReadableEvent();
+Kernel::KReadableEvent& AppletDataBroker::GetNormalDataEvent() {
+ return pop_out_data_event.GetReadableEvent();
}
-std::shared_ptr<Kernel::KReadableEvent> AppletDataBroker::GetInteractiveDataEvent() const {
- return pop_interactive_out_data_event->GetReadableEvent();
+Kernel::KReadableEvent& AppletDataBroker::GetInteractiveDataEvent() {
+ return pop_interactive_out_data_event.GetReadableEvent();
}
-std::shared_ptr<Kernel::KReadableEvent> AppletDataBroker::GetStateChangedEvent() const {
- return state_changed_event->GetReadableEvent();
+Kernel::KReadableEvent& AppletDataBroker::GetStateChangedEvent() {
+ return state_changed_event.GetReadableEvent();
}
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 4215d2232..5c0b4b459 100644
--- a/src/core/hle/service/am/applets/applets.h
+++ b/src/core/hle/service/am/applets/applets.h
@@ -8,7 +8,7 @@
#include <queue>
#include "common/swap.h"
-#include "core/hle/kernel/object.h"
+#include "core/hle/kernel/k_event.h"
union ResultCode;
@@ -95,11 +95,11 @@ public:
void PushInteractiveDataFromGame(std::shared_ptr<IStorage>&& storage);
void PushInteractiveDataFromApplet(std::shared_ptr<IStorage>&& storage);
- void SignalStateChanged() const;
+ void SignalStateChanged();
- std::shared_ptr<Kernel::KReadableEvent> GetNormalDataEvent() const;
- std::shared_ptr<Kernel::KReadableEvent> GetInteractiveDataEvent() const;
- std::shared_ptr<Kernel::KReadableEvent> GetStateChangedEvent() const;
+ Kernel::KReadableEvent& GetNormalDataEvent();
+ Kernel::KReadableEvent& GetInteractiveDataEvent();
+ Kernel::KReadableEvent& GetStateChangedEvent();
private:
Core::System& system;
@@ -119,13 +119,13 @@ private:
// PopInteractiveDataToGame and PushInteractiveDataFromApplet
std::deque<std::shared_ptr<IStorage>> out_interactive_channel;
- std::shared_ptr<Kernel::KEvent> state_changed_event;
+ Kernel::KEvent state_changed_event;
// Signaled on PushNormalDataFromApplet
- std::shared_ptr<Kernel::KEvent> pop_out_data_event;
+ Kernel::KEvent pop_out_data_event;
// Signaled on PushInteractiveDataFromApplet
- std::shared_ptr<Kernel::KEvent> pop_interactive_out_data_event;
+ Kernel::KEvent pop_interactive_out_data_event;
};
class Applet {
diff --git a/src/core/hle/service/am/applets/error.cpp b/src/core/hle/service/am/applets/error.cpp
index 0dd6ec68e..08348b180 100644
--- a/src/core/hle/service/am/applets/error.cpp
+++ b/src/core/hle/service/am/applets/error.cpp
@@ -9,7 +9,7 @@
#include "common/string_util.h"
#include "core/core.h"
#include "core/frontend/applets/error.h"
-#include "core/hle/kernel/process.h"
+#include "core/hle/kernel/k_process.h"
#include "core/hle/service/am/am.h"
#include "core/hle/service/am/applets/error.h"
#include "core/reporter.h"
diff --git a/src/core/hle/service/am/applets/general_backend.cpp b/src/core/hle/service/am/applets/general_backend.cpp
index b7483261e..e95499edd 100644
--- a/src/core/hle/service/am/applets/general_backend.cpp
+++ b/src/core/hle/service/am/applets/general_backend.cpp
@@ -9,7 +9,7 @@
#include "common/logging/log.h"
#include "core/core.h"
#include "core/frontend/applets/general_frontend.h"
-#include "core/hle/kernel/process.h"
+#include "core/hle/kernel/k_process.h"
#include "core/hle/result.h"
#include "core/hle/service/am/am.h"
#include "core/hle/service/am/applets/general_backend.h"
diff --git a/src/core/hle/service/am/applets/web_browser.cpp b/src/core/hle/service/am/applets/web_browser.cpp
index 2404921fd..e5f4a4485 100644
--- a/src/core/hle/service/am/applets/web_browser.cpp
+++ b/src/core/hle/service/am/applets/web_browser.cpp
@@ -17,7 +17,7 @@
#include "core/file_sys/system_archive/system_archive.h"
#include "core/file_sys/vfs_vector.h"
#include "core/frontend/applets/web_browser.h"
-#include "core/hle/kernel/process.h"
+#include "core/hle/kernel/k_process.h"
#include "core/hle/result.h"
#include "core/hle/service/am/am.h"
#include "core/hle/service/am/applets/web_browser.h"
diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp
index 75867e349..1863260f1 100644
--- a/src/core/hle/service/aoc/aoc_u.cpp
+++ b/src/core/hle/service/aoc/aoc_u.cpp
@@ -16,10 +16,9 @@
#include "core/file_sys/patch_manager.h"
#include "core/file_sys/registered_cache.h"
#include "core/hle/ipc_helpers.h"
-#include "core/hle/kernel/k_event.h"
+#include "core/hle/kernel/k_process.h"
#include "core/hle/kernel/k_readable_event.h"
#include "core/hle/kernel/kernel.h"
-#include "core/hle/kernel/process.h"
#include "core/hle/service/aoc/aoc_u.h"
#include "core/loader/loader.h"
@@ -50,7 +49,7 @@ static std::vector<u64> AccumulateAOCTitleIDs(Core::System& system) {
class IPurchaseEventManager final : public ServiceFramework<IPurchaseEventManager> {
public:
explicit IPurchaseEventManager(Core::System& system_)
- : ServiceFramework{system_, "IPurchaseEventManager"} {
+ : ServiceFramework{system_, "IPurchaseEventManager"}, purchased_event{system.Kernel()} {
// clang-format off
static const FunctionInfo functions[] = {
{0, &IPurchaseEventManager::SetDefaultDeliveryTarget, "SetDefaultDeliveryTarget"},
@@ -63,9 +62,8 @@ public:
RegisterHandlers(functions);
- purchased_event =
- Kernel::KEvent::Create(system.Kernel(), "IPurchaseEventManager:PurchasedEvent");
- purchased_event->Initialize();
+ Kernel::KAutoObject::Create(std::addressof(purchased_event));
+ purchased_event.Initialize("IPurchaseEventManager:PurchasedEvent");
}
private:
@@ -98,14 +96,15 @@ private:
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(purchased_event->GetReadableEvent());
+ rb.PushCopyObjects(purchased_event.GetReadableEvent());
}
- std::shared_ptr<Kernel::KEvent> purchased_event;
+ Kernel::KEvent purchased_event;
};
AOC_U::AOC_U(Core::System& system_)
- : ServiceFramework{system_, "aoc:u"}, add_on_content{AccumulateAOCTitleIDs(system)} {
+ : ServiceFramework{system_, "aoc:u"}, add_on_content{AccumulateAOCTitleIDs(system)},
+ aoc_change_event{system.Kernel()} {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "CountAddOnContentByApplicationId"},
@@ -127,9 +126,8 @@ AOC_U::AOC_U(Core::System& system_)
RegisterHandlers(functions);
- auto& kernel = system.Kernel();
- aoc_change_event = Kernel::KEvent::Create(kernel, "GetAddOnContentListChanged:Event");
- aoc_change_event->Initialize();
+ Kernel::KAutoObject::Create(std::addressof(aoc_change_event));
+ aoc_change_event.Initialize("GetAddOnContentListChanged:Event");
}
AOC_U::~AOC_U() = default;
@@ -256,7 +254,7 @@ void AOC_U::GetAddOnContentListChangedEvent(Kernel::HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(aoc_change_event->GetReadableEvent());
+ rb.PushCopyObjects(aoc_change_event.GetReadableEvent());
}
void AOC_U::CreateEcPurchasedEventManager(Kernel::HLERequestContext& ctx) {
diff --git a/src/core/hle/service/aoc/aoc_u.h b/src/core/hle/service/aoc/aoc_u.h
index 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 @@
#pragma once
+#include "core/hle/kernel/k_event.h"
#include "core/hle/service/service.h"
namespace Core {
@@ -31,7 +32,7 @@ private:
void CreatePermanentEcPurchasedEventManager(Kernel::HLERequestContext& ctx);
std::vector<u64> add_on_content;
- std::shared_ptr<Kernel::KEvent> aoc_change_event;
+ Kernel::KEvent aoc_change_event;
};
/// Registers all AOC services with the specified service manager.
diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp
index 5f51fca9a..e1ae726f5 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> {
public:
IAudioOut(Core::System& system_, AudoutParams audio_params_, AudioCore::AudioOut& audio_core_,
std::string&& device_name_, std::string&& unique_name)
- : ServiceFramework{system_, "IAudioOut"}, audio_core{audio_core_},
- device_name{std::move(device_name_)}, audio_params{audio_params_}, main_memory{
- system.Memory()} {
+ : ServiceFramework{system_, "IAudioOut"}, audio_core{audio_core_}, device_name{std::move(
+ device_name_)},
+ audio_params{audio_params_}, buffer_event{system.Kernel()}, main_memory{system.Memory()} {
// clang-format off
static const FunctionInfo functions[] = {
{0, &IAudioOut::GetAudioOutState, "GetAudioOutState"},
@@ -67,13 +67,13 @@ public:
RegisterHandlers(functions);
// This is the event handle used to check if the audio buffer was released
- buffer_event = Kernel::KEvent::Create(system.Kernel(), "IAudioOutBufferReleased");
- buffer_event->Initialize();
+ Kernel::KAutoObject::Create(std::addressof(buffer_event));
+ buffer_event.Initialize("IAudioOutBufferReleased");
stream = audio_core.OpenStream(system.CoreTiming(), audio_params.sample_rate,
audio_params.channel_count, std::move(unique_name), [this] {
const auto guard = LockService();
- buffer_event->GetWritableEvent()->Signal();
+ buffer_event.GetWritableEvent().Signal();
});
}
@@ -126,7 +126,7 @@ private:
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(buffer_event->GetReadableEvent());
+ rb.PushCopyObjects(buffer_event.GetReadableEvent());
}
void AppendAudioOutBufferImpl(Kernel::HLERequestContext& ctx) {
@@ -220,7 +220,7 @@ private:
[[maybe_unused]] AudoutParams audio_params{};
/// This is the event handle used to check if the audio buffer was released
- std::shared_ptr<Kernel::KEvent> buffer_event;
+ Kernel::KEvent buffer_event;
Core::Memory::Memory& main_memory;
};
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp
index 3a48342fd..513bd3730 100644
--- a/src/core/hle/service/audio/audren_u.cpp
+++ b/src/core/hle/service/audio/audren_u.cpp
@@ -30,7 +30,7 @@ public:
explicit IAudioRenderer(Core::System& system_,
const AudioCommon::AudioRendererParameter& audren_params,
const std::size_t instance_number)
- : ServiceFramework{system_, "IAudioRenderer"} {
+ : ServiceFramework{system_, "IAudioRenderer"}, system_event{system.Kernel()} {
// clang-format off
static const FunctionInfo functions[] = {
{0, &IAudioRenderer::GetSampleRate, "GetSampleRate"},
@@ -49,13 +49,13 @@ public:
// clang-format on
RegisterHandlers(functions);
- system_event = Kernel::KEvent::Create(system.Kernel(), "IAudioRenderer:SystemEvent");
- system_event->Initialize();
+ Kernel::KAutoObject::Create(std::addressof(system_event));
+ system_event.Initialize("IAudioRenderer:SystemEvent");
renderer = std::make_unique<AudioCore::AudioRenderer>(
system.CoreTiming(), system.Memory(), audren_params,
[this]() {
const auto guard = LockService();
- system_event->GetWritableEvent()->Signal();
+ system_event.GetWritableEvent().Signal();
},
instance_number);
}
@@ -128,7 +128,7 @@ private:
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(system_event->GetReadableEvent());
+ rb.PushCopyObjects(system_event.GetReadableEvent());
}
void SetRenderingTimeLimit(Kernel::HLERequestContext& ctx) {
@@ -162,7 +162,7 @@ private:
rb.Push(ERR_NOT_SUPPORTED);
}
- std::shared_ptr<Kernel::KEvent> system_event;
+ Kernel::KEvent system_event;
std::unique_ptr<AudioCore::AudioRenderer> renderer;
u32 rendering_time_limit_percent = 100;
};
@@ -170,7 +170,9 @@ private:
class IAudioDevice final : public ServiceFramework<IAudioDevice> {
public:
explicit IAudioDevice(Core::System& system_, u32_le revision_num)
- : ServiceFramework{system_, "IAudioDevice"}, revision{revision_num} {
+ : ServiceFramework{system_, "IAudioDevice"}, revision{revision_num},
+ buffer_event{system.Kernel()}, audio_input_device_switch_event{system.Kernel()},
+ audio_output_device_switch_event{system.Kernel()} {
static const FunctionInfo functions[] = {
{0, &IAudioDevice::ListAudioDeviceName, "ListAudioDeviceName"},
{1, &IAudioDevice::SetAudioDeviceOutputVolume, "SetAudioDeviceOutputVolume"},
@@ -188,20 +190,17 @@ public:
};
RegisterHandlers(functions);
- auto& kernel = system.Kernel();
- buffer_event = Kernel::KEvent::Create(kernel, "IAudioOutBufferReleasedEvent");
- buffer_event->Initialize();
+ Kernel::KAutoObject::Create(std::addressof(buffer_event));
+ buffer_event.Initialize("IAudioOutBufferReleasedEvent");
// Should be similar to audio_output_device_switch_event
- audio_input_device_switch_event =
- Kernel::KEvent::Create(kernel, "IAudioDevice:AudioInputDeviceSwitchedEvent");
- audio_input_device_switch_event->Initialize();
+ Kernel::KAutoObject::Create(std::addressof(audio_input_device_switch_event));
+ audio_input_device_switch_event.Initialize("IAudioDevice:AudioInputDeviceSwitchedEvent");
// Should only be signalled when an audio output device has been changed, example: speaker
// to headset
- audio_output_device_switch_event =
- Kernel::KEvent::Create(kernel, "IAudioDevice:AudioOutputDeviceSwitchedEvent");
- audio_output_device_switch_event->Initialize();
+ Kernel::KAutoObject::Create(std::addressof(audio_output_device_switch_event));
+ audio_output_device_switch_event.Initialize("IAudioDevice:AudioOutputDeviceSwitchedEvent");
}
private:
@@ -290,11 +289,11 @@ private:
void QueryAudioDeviceSystemEvent(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_Audio, "(STUBBED) called");
- buffer_event->GetWritableEvent()->Signal();
+ buffer_event.GetWritableEvent().Signal();
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(buffer_event->GetReadableEvent());
+ rb.PushCopyObjects(buffer_event.GetReadableEvent());
}
void GetActiveChannelCount(Kernel::HLERequestContext& ctx) {
@@ -311,7 +310,7 @@ private:
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(audio_input_device_switch_event->GetReadableEvent());
+ rb.PushCopyObjects(audio_input_device_switch_event.GetReadableEvent());
}
void QueryAudioDeviceOutputEvent(Kernel::HLERequestContext& ctx) {
@@ -319,13 +318,13 @@ private:
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(audio_output_device_switch_event->GetReadableEvent());
+ rb.PushCopyObjects(audio_output_device_switch_event.GetReadableEvent());
}
u32_le revision = 0;
- std::shared_ptr<Kernel::KEvent> buffer_event;
- std::shared_ptr<Kernel::KEvent> audio_input_device_switch_event;
- std::shared_ptr<Kernel::KEvent> audio_output_device_switch_event;
+ Kernel::KEvent buffer_event;
+ Kernel::KEvent audio_input_device_switch_event;
+ Kernel::KEvent audio_output_device_switch_event;
}; // namespace Audio
diff --git a/src/core/hle/service/bcat/backend/backend.cpp b/src/core/hle/service/bcat/backend/backend.cpp
index 92d25dbe4..0e935bfa6 100644
--- a/src/core/hle/service/bcat/backend/backend.cpp
+++ b/src/core/hle/service/bcat/backend/backend.cpp
@@ -5,7 +5,6 @@
#include "common/hex_util.h"
#include "common/logging/log.h"
#include "core/core.h"
-#include "core/hle/kernel/k_event.h"
#include "core/hle/kernel/k_readable_event.h"
#include "core/hle/kernel/k_writable_event.h"
#include "core/hle/lock.h"
@@ -14,14 +13,14 @@
namespace Service::BCAT {
ProgressServiceBackend::ProgressServiceBackend(Kernel::KernelCore& kernel,
- std::string_view event_name) {
- event = Kernel::KEvent::Create(kernel,
- "ProgressServiceBackend:UpdateEvent:" + std::string(event_name));
- event->Initialize();
+ std::string_view event_name)
+ : update_event{kernel} {
+ Kernel::KAutoObject::Create(std::addressof(update_event));
+ update_event.Initialize("ProgressServiceBackend:UpdateEvent:" + std::string(event_name));
}
-std::shared_ptr<Kernel::KReadableEvent> ProgressServiceBackend::GetEvent() const {
- return event->GetReadableEvent();
+Kernel::KReadableEvent& ProgressServiceBackend::GetEvent() {
+ return update_event.GetReadableEvent();
}
DeliveryCacheProgressImpl& ProgressServiceBackend::GetImpl() {
@@ -86,12 +85,12 @@ void ProgressServiceBackend::FinishDownload(ResultCode result) {
SignalUpdate();
}
-void ProgressServiceBackend::SignalUpdate() const {
+void ProgressServiceBackend::SignalUpdate() {
if (need_hle_lock) {
std::lock_guard lock(HLE::g_hle_lock);
- event->GetWritableEvent()->Signal();
+ update_event.GetWritableEvent().Signal();
} else {
- event->GetWritableEvent()->Signal();
+ update_event.GetWritableEvent().Signal();
}
}
diff --git a/src/core/hle/service/bcat/backend/backend.h b/src/core/hle/service/bcat/backend/backend.h
index db585b069..f591a362a 100644
--- a/src/core/hle/service/bcat/backend/backend.h
+++ b/src/core/hle/service/bcat/backend/backend.h
@@ -11,6 +11,7 @@
#include "common/common_types.h"
#include "core/file_sys/vfs_types.h"
+#include "core/hle/kernel/k_event.h"
#include "core/hle/result.h"
namespace Core {
@@ -98,13 +99,13 @@ public:
private:
explicit ProgressServiceBackend(Kernel::KernelCore& kernel, std::string_view event_name);
- std::shared_ptr<Kernel::KReadableEvent> GetEvent() const;
+ Kernel::KReadableEvent& GetEvent();
DeliveryCacheProgressImpl& GetImpl();
- void SignalUpdate() const;
+ void SignalUpdate();
DeliveryCacheProgressImpl impl{};
- std::shared_ptr<Kernel::KEvent> event;
+ Kernel::KEvent update_event;
bool need_hle_lock = false;
};
diff --git a/src/core/hle/service/bcat/module.cpp b/src/core/hle/service/bcat/module.cpp
index 285085f2a..0206cbb6a 100644
--- a/src/core/hle/service/bcat/module.cpp
+++ b/src/core/hle/service/bcat/module.cpp
@@ -12,9 +12,9 @@
#include "core/core.h"
#include "core/file_sys/vfs.h"
#include "core/hle/ipc_helpers.h"
+#include "core/hle/kernel/k_process.h"
#include "core/hle/kernel/k_readable_event.h"
#include "core/hle/kernel/k_writable_event.h"
-#include "core/hle/kernel/process.h"
#include "core/hle/service/bcat/backend/backend.h"
#include "core/hle/service/bcat/bcat.h"
#include "core/hle/service/bcat/module.h"
@@ -88,11 +88,9 @@ struct DeliveryCacheDirectoryEntry {
class IDeliveryCacheProgressService final : public ServiceFramework<IDeliveryCacheProgressService> {
public:
- explicit IDeliveryCacheProgressService(Core::System& system_,
- std::shared_ptr<Kernel::KReadableEvent> event_,
+ explicit IDeliveryCacheProgressService(Core::System& system_, Kernel::KReadableEvent& event_,
const DeliveryCacheProgressImpl& impl_)
- : ServiceFramework{system_, "IDeliveryCacheProgressService"}, event{std::move(event_)},
- impl{impl_} {
+ : ServiceFramework{system_, "IDeliveryCacheProgressService"}, event{event_}, impl{impl_} {
// clang-format off
static const FunctionInfo functions[] = {
{0, &IDeliveryCacheProgressService::GetEvent, "GetEvent"},
@@ -121,7 +119,7 @@ private:
rb.Push(RESULT_SUCCESS);
}
- std::shared_ptr<Kernel::KReadableEvent> event;
+ Kernel::KReadableEvent& event;
const DeliveryCacheProgressImpl& impl;
};
diff --git a/src/core/hle/service/btdrv/btdrv.cpp b/src/core/hle/service/btdrv/btdrv.cpp
index af3a5842d..fd97a822c 100644
--- a/src/core/hle/service/btdrv/btdrv.cpp
+++ b/src/core/hle/service/btdrv/btdrv.cpp
@@ -17,7 +17,8 @@ namespace Service::BtDrv {
class Bt final : public ServiceFramework<Bt> {
public:
- explicit Bt(Core::System& system_) : ServiceFramework{system_, "bt"} {
+ explicit Bt(Core::System& system_)
+ : ServiceFramework{system_, "bt"}, register_event{system.Kernel()} {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "LeClientReadCharacteristic"},
@@ -34,9 +35,8 @@ public:
// clang-format on
RegisterHandlers(functions);
- auto& kernel = system.Kernel();
- register_event = Kernel::KEvent::Create(kernel, "BT:RegisterEvent");
- register_event->Initialize();
+ Kernel::KAutoObject::Create(std::addressof(register_event));
+ register_event.Initialize("BT:RegisterEvent");
}
private:
@@ -45,10 +45,10 @@ private:
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(register_event->GetReadableEvent());
+ rb.PushCopyObjects(register_event.GetReadableEvent());
}
- std::shared_ptr<Kernel::KEvent> register_event;
+ Kernel::KEvent register_event;
};
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..3b5ef69e1 100644
--- a/src/core/hle/service/btm/btm.cpp
+++ b/src/core/hle/service/btm/btm.cpp
@@ -18,7 +18,10 @@ namespace Service::BTM {
class IBtmUserCore final : public ServiceFramework<IBtmUserCore> {
public:
- explicit IBtmUserCore(Core::System& system_) : ServiceFramework{system_, "IBtmUserCore"} {
+ explicit IBtmUserCore(Core::System& system_)
+ : ServiceFramework{system_, "IBtmUserCore"}, scan_event{system.Kernel()},
+ connection_event{system.Kernel()}, service_discovery{system.Kernel()},
+ config_event{system.Kernel()} {
// clang-format off
static const FunctionInfo functions[] = {
{0, &IBtmUserCore::AcquireBleScanEvent, "AcquireBleScanEvent"},
@@ -57,15 +60,15 @@ public:
// clang-format on
RegisterHandlers(functions);
- auto& kernel = system.Kernel();
- scan_event = Kernel::KEvent::Create(kernel, "IBtmUserCore:ScanEvent");
- scan_event->Initialize();
- connection_event = Kernel::KEvent::Create(kernel, "IBtmUserCore:ConnectionEvent");
- connection_event->Initialize();
- service_discovery = Kernel::KEvent::Create(kernel, "IBtmUserCore:Discovery");
- service_discovery->Initialize();
- config_event = Kernel::KEvent::Create(kernel, "IBtmUserCore:ConfigEvent");
- config_event->Initialize();
+ Kernel::KAutoObject::Create(std::addressof(scan_event));
+ Kernel::KAutoObject::Create(std::addressof(connection_event));
+ Kernel::KAutoObject::Create(std::addressof(service_discovery));
+ Kernel::KAutoObject::Create(std::addressof(config_event));
+
+ scan_event.Initialize("IBtmUserCore:ScanEvent");
+ connection_event.Initialize("IBtmUserCore:ConnectionEvent");
+ service_discovery.Initialize("IBtmUserCore:Discovery");
+ config_event.Initialize("IBtmUserCore:ConfigEvent");
}
private:
@@ -74,7 +77,7 @@ private:
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(scan_event->GetReadableEvent());
+ rb.PushCopyObjects(scan_event.GetReadableEvent());
}
void AcquireBleConnectionEvent(Kernel::HLERequestContext& ctx) {
@@ -82,7 +85,7 @@ private:
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(connection_event->GetReadableEvent());
+ rb.PushCopyObjects(connection_event.GetReadableEvent());
}
void AcquireBleServiceDiscoveryEvent(Kernel::HLERequestContext& ctx) {
@@ -90,7 +93,7 @@ private:
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(service_discovery->GetReadableEvent());
+ rb.PushCopyObjects(service_discovery.GetReadableEvent());
}
void AcquireBleMtuConfigEvent(Kernel::HLERequestContext& ctx) {
@@ -98,13 +101,13 @@ private:
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(config_event->GetReadableEvent());
+ rb.PushCopyObjects(config_event.GetReadableEvent());
}
- std::shared_ptr<Kernel::KEvent> scan_event;
- std::shared_ptr<Kernel::KEvent> connection_event;
- std::shared_ptr<Kernel::KEvent> service_discovery;
- std::shared_ptr<Kernel::KEvent> config_event;
+ Kernel::KEvent scan_event;
+ Kernel::KEvent connection_event;
+ Kernel::KEvent service_discovery;
+ Kernel::KEvent config_event;
};
class BTM_USR final : public ServiceFramework<BTM_USR> {
diff --git a/src/core/hle/service/fatal/fatal.cpp b/src/core/hle/service/fatal/fatal.cpp
index 13147472e..432abde76 100644
--- a/src/core/hle/service/fatal/fatal.cpp
+++ b/src/core/hle/service/fatal/fatal.cpp
@@ -12,7 +12,7 @@
#include "common/swap.h"
#include "core/core.h"
#include "core/hle/ipc_helpers.h"
-#include "core/hle/kernel/process.h"
+#include "core/hle/kernel/k_process.h"
#include "core/hle/service/fatal/fatal.h"
#include "core/hle/service/fatal/fatal_p.h"
#include "core/hle/service/fatal/fatal_u.h"
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp
index 67b2b3102..67baaee9b 100644
--- a/src/core/hle/service/filesystem/filesystem.cpp
+++ b/src/core/hle/service/filesystem/filesystem.cpp
@@ -21,7 +21,7 @@
#include "core/file_sys/sdmc_factory.h"
#include "core/file_sys/vfs.h"
#include "core/file_sys/vfs_offset.h"
-#include "core/hle/kernel/process.h"
+#include "core/hle/kernel/k_process.h"
#include "core/hle/service/filesystem/filesystem.h"
#include "core/hle/service/filesystem/fsp_ldr.h"
#include "core/hle/service/filesystem/fsp_pr.h"
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp
index 7dc487e48..92ea27074 100644
--- a/src/core/hle/service/filesystem/fsp_srv.cpp
+++ b/src/core/hle/service/filesystem/fsp_srv.cpp
@@ -25,7 +25,7 @@
#include "core/file_sys/system_archive/system_archive.h"
#include "core/file_sys/vfs.h"
#include "core/hle/ipc_helpers.h"
-#include "core/hle/kernel/process.h"
+#include "core/hle/kernel/k_process.h"
#include "core/hle/service/filesystem/filesystem.h"
#include "core/hle/service/filesystem/fsp_srv.h"
#include "core/reporter.h"
diff --git a/src/core/hle/service/friend/friend.cpp b/src/core/hle/service/friend/friend.cpp
index a35979053..91c202952 100644
--- a/src/core/hle/service/friend/friend.cpp
+++ b/src/core/hle/service/friend/friend.cpp
@@ -185,7 +185,8 @@ private:
class INotificationService final : public ServiceFramework<INotificationService> {
public:
explicit INotificationService(Common::UUID uuid_, Core::System& system_)
- : ServiceFramework{system_, "INotificationService"}, uuid{uuid_} {
+ : ServiceFramework{system_, "INotificationService"}, uuid{uuid_}, notification_event{
+ system.Kernel()} {
// clang-format off
static const FunctionInfo functions[] = {
{0, &INotificationService::GetEvent, "GetEvent"},
@@ -196,9 +197,8 @@ public:
RegisterHandlers(functions);
- notification_event =
- Kernel::KEvent::Create(system.Kernel(), "INotificationService:NotifyEvent");
- notification_event->Initialize();
+ Kernel::KAutoObject::Create(std::addressof(notification_event));
+ notification_event.Initialize("INotificationService:NotifyEvent");
}
private:
@@ -207,7 +207,7 @@ private:
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(notification_event->GetReadableEvent());
+ rb.PushCopyObjects(notification_event.GetReadableEvent());
}
void Clear(Kernel::HLERequestContext& ctx) {
@@ -273,7 +273,7 @@ private:
};
Common::UUID uuid{Common::INVALID_UUID};
- std::shared_ptr<Kernel::KEvent> notification_event;
+ Kernel::KEvent notification_event;
std::queue<SizedNotificationInfo> notifications;
States states{};
};
diff --git a/src/core/hle/service/glue/arp.cpp b/src/core/hle/service/glue/arp.cpp
index 7b1c6677c..6ad62ee5a 100644
--- a/src/core/hle/service/glue/arp.cpp
+++ b/src/core/hle/service/glue/arp.cpp
@@ -9,8 +9,8 @@
#include "core/file_sys/control_metadata.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/kernel/hle_ipc.h"
+#include "core/hle/kernel/k_process.h"
#include "core/hle/kernel/kernel.h"
-#include "core/hle/kernel/process.h"
#include "core/hle/service/glue/arp.h"
#include "core/hle/service/glue/errors.h"
#include "core/hle/service/glue/manager.h"
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp
index d4678ef49..7acad3798 100644
--- a/src/core/hle/service/hid/controllers/npad.cpp
+++ b/src/core/hle/service/hid/controllers/npad.cpp
@@ -159,7 +159,7 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) {
const auto controller_type = connected_controllers[controller_idx].type;
auto& controller = shared_memory_entries[controller_idx];
if (controller_type == NPadControllerType::None) {
- styleset_changed_events[controller_idx]->GetWritableEvent()->Signal();
+ styleset_changed_events[controller_idx]->GetWritableEvent().Signal();
return;
}
controller.style_set.raw = 0; // Zero out
@@ -253,9 +253,8 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) {
void Controller_NPad::OnInit() {
auto& kernel = system.Kernel();
for (std::size_t i = 0; i < styleset_changed_events.size(); ++i) {
- styleset_changed_events[i] =
- Kernel::KEvent::Create(kernel, fmt::format("npad:NpadStyleSetChanged_{}", i));
- styleset_changed_events[i]->Initialize();
+ styleset_changed_events[i] = Kernel::KEvent::Create(kernel);
+ styleset_changed_events[i]->Initialize(fmt::format("npad:NpadStyleSetChanged_{}", i));
}
if (!IsControllerActivated()) {
@@ -341,6 +340,11 @@ void Controller_NPad::OnRelease() {
VibrateControllerAtIndex(npad_idx, device_idx, {});
}
}
+
+ for (std::size_t i = 0; i < styleset_changed_events.size(); ++i) {
+ styleset_changed_events[i]->Close();
+ styleset_changed_events[i] = nullptr;
+ }
}
void Controller_NPad::RequestPadStateUpdate(u32 npad_id) {
@@ -955,14 +959,12 @@ bool Controller_NPad::IsVibrationDeviceMounted(const DeviceHandle& vibration_dev
return vibration_devices_mounted[npad_index][device_index];
}
-std::shared_ptr<Kernel::KReadableEvent> Controller_NPad::GetStyleSetChangedEvent(
- u32 npad_id) const {
- const auto& styleset_event = styleset_changed_events[NPadIdToIndex(npad_id)];
- return styleset_event->GetReadableEvent();
+Kernel::KReadableEvent& Controller_NPad::GetStyleSetChangedEvent(u32 npad_id) {
+ return styleset_changed_events[NPadIdToIndex(npad_id)]->GetReadableEvent();
}
void Controller_NPad::SignalStyleSetChangedEvent(u32 npad_id) const {
- styleset_changed_events[NPadIdToIndex(npad_id)]->GetWritableEvent()->Signal();
+ styleset_changed_events[NPadIdToIndex(npad_id)]->GetWritableEvent().Signal();
}
void Controller_NPad::AddNewControllerAt(NPadControllerType controller, std::size_t npad_index) {
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h
index ea484d4bf..c050c9a44 100644
--- a/src/core/hle/service/hid/controllers/npad.h
+++ b/src/core/hle/service/hid/controllers/npad.h
@@ -11,7 +11,6 @@
#include "common/quaternion.h"
#include "common/settings.h"
#include "core/frontend/input.h"
-#include "core/hle/kernel/object.h"
#include "core/hle/service/hid/controllers/controller_base.h"
namespace Kernel {
@@ -199,7 +198,7 @@ public:
bool IsVibrationDeviceMounted(const DeviceHandle& vibration_device_handle) const;
- std::shared_ptr<Kernel::KReadableEvent> GetStyleSetChangedEvent(u32 npad_id) const;
+ Kernel::KReadableEvent& GetStyleSetChangedEvent(u32 npad_id);
void SignalStyleSetChangedEvent(u32 npad_id) const;
// Adds a new controller at an index.
@@ -573,8 +572,9 @@ private:
NpadHandheldActivationMode handheld_activation_mode{NpadHandheldActivationMode::Dual};
NpadCommunicationMode communication_mode{NpadCommunicationMode::Default};
// Each controller should have their own styleset changed event
- std::array<std::shared_ptr<Kernel::KEvent>, 10> styleset_changed_events;
- std::array<std::array<std::chrono::steady_clock::time_point, 2>, 10> last_vibration_timepoints;
+ std::array<Kernel::KEvent*, 10> styleset_changed_events{};
+ std::array<std::array<std::chrono::steady_clock::time_point, 2>, 10>
+ last_vibration_timepoints{};
std::array<std::array<VibrationValue, 2>, 10> latest_vibration_values{};
bool permit_vibration_session_enabled{false};
std::array<std::array<bool, 2>, 10> vibration_devices_mounted{};
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index 9c4bf6d16..49c17fd14 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -13,18 +13,18 @@
#include "core/frontend/input.h"
#include "core/hardware_properties.h"
#include "core/hle/ipc_helpers.h"
-#include "core/hle/kernel/client_port.h"
-#include "core/hle/kernel/client_session.h"
+#include "core/hle/kernel/k_client_port.h"
#include "core/hle/kernel/k_readable_event.h"
#include "core/hle/kernel/k_shared_memory.h"
+#include "core/hle/kernel/k_transfer_memory.h"
#include "core/hle/kernel/k_writable_event.h"
#include "core/hle/kernel/kernel.h"
-#include "core/hle/kernel/transfer_memory.h"
#include "core/hle/service/hid/errors.h"
#include "core/hle/service/hid/hid.h"
#include "core/hle/service/hid/irs.h"
#include "core/hle/service/hid/xcd.h"
#include "core/hle/service/service.h"
+#include "core/memory.h"
#include "core/hle/service/hid/controllers/console_sixaxis.h"
#include "core/hle/service/hid/controllers/controller_base.h"
@@ -53,9 +53,6 @@ IAppletResource::IAppletResource(Core::System& system_)
};
RegisterHandlers(functions);
- auto& kernel = system.Kernel();
- shared_mem = SharedFrom(&kernel.GetHidSharedMem());
-
MakeController<Controller_DebugPad>(HidController::DebugPad);
MakeController<Controller_Touchscreen>(HidController::Touchscreen);
MakeController<Controller_Mouse>(HidController::Mouse);
@@ -118,7 +115,7 @@ void IAppletResource::GetSharedMemoryHandle(Kernel::HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(shared_mem);
+ rb.PushCopyObjects(&system.Kernel().GetHidSharedMem());
}
void IAppletResource::UpdateControllers(std::uintptr_t user_data,
@@ -130,7 +127,8 @@ void IAppletResource::UpdateControllers(std::uintptr_t user_data,
if (should_reload) {
controller->OnLoadInputDevices();
}
- controller->OnUpdate(core_timing, shared_mem->GetPointer(), SHARED_MEMORY_SIZE);
+ controller->OnUpdate(core_timing, system.Kernel().GetHidSharedMem().GetPointer(),
+ SHARED_MEMORY_SIZE);
}
// If ns_late is higher than the update rate ignore the delay
@@ -145,7 +143,7 @@ void IAppletResource::UpdateMotion(std::uintptr_t user_data, std::chrono::nanose
auto& core_timing = system.CoreTiming();
controllers[static_cast<size_t>(HidController::NPad)]->OnMotionUpdate(
- core_timing, shared_mem->GetPointer(), SHARED_MEMORY_SIZE);
+ core_timing, system.Kernel().GetHidSharedMem().GetPointer(), SHARED_MEMORY_SIZE);
// If ns_late is higher than the update rate ignore the delay
if (ns_late > motion_update_ns) {
@@ -1496,20 +1494,20 @@ void Hid::InitializeSevenSixAxisSensor(Kernel::HLERequestContext& ctx) {
ASSERT_MSG(t_mem_1_size == 0x1000, "t_mem_1_size is not 0x1000 bytes");
ASSERT_MSG(t_mem_2_size == 0x7F000, "t_mem_2_size is not 0x7F000 bytes");
- auto t_mem_1 =
- system.CurrentProcess()->GetHandleTable().Get<Kernel::TransferMemory>(t_mem_1_handle);
+ auto t_mem_1 = system.CurrentProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(
+ t_mem_1_handle);
- if (t_mem_1 == nullptr) {
+ if (t_mem_1.IsNull()) {
LOG_ERROR(Service_HID, "t_mem_1 is a nullptr for handle=0x{:08X}", t_mem_1_handle);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_UNKNOWN);
return;
}
- auto t_mem_2 =
- system.CurrentProcess()->GetHandleTable().Get<Kernel::TransferMemory>(t_mem_2_handle);
+ auto t_mem_2 = system.CurrentProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(
+ t_mem_2_handle);
- if (t_mem_2 == nullptr) {
+ if (t_mem_2.IsNull()) {
LOG_ERROR(Service_HID, "t_mem_2 is a nullptr for handle=0x{:08X}", t_mem_2_handle);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_UNKNOWN);
@@ -1524,7 +1522,7 @@ void Hid::InitializeSevenSixAxisSensor(Kernel::HLERequestContext& ctx) {
.ActivateController();
applet_resource->GetController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor)
- .SetTransferMemoryPointer(t_mem_1->GetPointer());
+ .SetTransferMemoryPointer(system.Memory().GetPointer(t_mem_1->GetSourceAddress()));
LOG_WARNING(Service_HID,
"called, t_mem_1_handle=0x{:08X}, t_mem_2_handle=0x{:08X}, "
diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h
index c2bdd39a3..aa3307955 100644
--- a/src/core/hle/service/hid/hid.h
+++ b/src/core/hle/service/hid/hid.h
@@ -13,10 +13,6 @@ namespace Core::Timing {
struct EventType;
}
-namespace Kernel {
-class KSharedMemory;
-}
-
namespace Service::SM {
class ServiceManager;
}
@@ -69,8 +65,6 @@ private:
void UpdateControllers(std::uintptr_t user_data, std::chrono::nanoseconds ns_late);
void UpdateMotion(std::uintptr_t user_data, std::chrono::nanoseconds ns_late);
- std::shared_ptr<Kernel::KSharedMemory> shared_mem;
-
std::shared_ptr<Core::Timing::EventType> pad_update_event;
std::shared_ptr<Core::Timing::EventType> motion_update_event;
diff --git a/src/core/hle/service/hid/irs.cpp b/src/core/hle/service/hid/irs.cpp
index 2dfa936fb..3c6085990 100644
--- a/src/core/hle/service/hid/irs.cpp
+++ b/src/core/hle/service/hid/irs.cpp
@@ -37,10 +37,6 @@ IRS::IRS(Core::System& system_) : ServiceFramework{system_, "irs"} {
// clang-format on
RegisterHandlers(functions);
-
- auto& kernel = system.Kernel();
-
- shared_mem = SharedFrom(&kernel.GetIrsSharedMem());
}
void IRS::ActivateIrsensor(Kernel::HLERequestContext& ctx) {
@@ -62,7 +58,7 @@ void IRS::GetIrsensorSharedMemoryHandle(Kernel::HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(shared_mem);
+ rb.PushCopyObjects(&system.Kernel().GetIrsSharedMem());
}
void IRS::StopImageProcessor(Kernel::HLERequestContext& ctx) {
diff --git a/src/core/hle/service/hid/irs.h b/src/core/hle/service/hid/irs.h
index b0c8c7168..9bc6462b0 100644
--- a/src/core/hle/service/hid/irs.h
+++ b/src/core/hle/service/hid/irs.h
@@ -4,17 +4,12 @@
#pragma once
-#include "core/hle/kernel/object.h"
#include "core/hle/service/service.h"
namespace Core {
class System;
}
-namespace Kernel {
-class KSharedMemory;
-}
-
namespace Service::HID {
class IRS final : public ServiceFramework<IRS> {
@@ -42,7 +37,6 @@ private:
void StopImageProcessorAsync(Kernel::HLERequestContext& ctx);
void ActivateIrsensorWithFunctionLevel(Kernel::HLERequestContext& ctx);
- std::shared_ptr<Kernel::KSharedMemory> shared_mem;
const u32 device_handle{0xABCD};
};
diff --git a/src/core/hle/service/ldr/ldr.cpp b/src/core/hle/service/ldr/ldr.cpp
index 89f6f6a2a..c3948eb8e 100644
--- a/src/core/hle/service/ldr/ldr.cpp
+++ b/src/core/hle/service/ldr/ldr.cpp
@@ -12,8 +12,8 @@
#include "core/core.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/kernel/k_page_table.h"
+#include "core/hle/kernel/k_process.h"
#include "core/hle/kernel/k_system_control.h"
-#include "core/hle/kernel/process.h"
#include "core/hle/kernel/svc_results.h"
#include "core/hle/service/ldr/ldr.h"
#include "core/hle/service/service.h"
@@ -321,7 +321,7 @@ public:
return addr;
}
- ResultVal<VAddr> MapProcessCodeMemory(Kernel::Process* process, VAddr baseAddress,
+ ResultVal<VAddr> MapProcessCodeMemory(Kernel::KProcess* process, VAddr baseAddress,
u64 size) const {
for (std::size_t retry = 0; retry < MAXIMUM_MAP_RETRIES; retry++) {
auto& page_table{process->PageTable()};
@@ -342,7 +342,7 @@ public:
return ERROR_INSUFFICIENT_ADDRESS_SPACE;
}
- ResultVal<VAddr> MapNro(Kernel::Process* process, VAddr nro_addr, std::size_t nro_size,
+ ResultVal<VAddr> MapNro(Kernel::KProcess* process, VAddr nro_addr, std::size_t nro_size,
VAddr bss_addr, std::size_t bss_size, std::size_t size) const {
for (std::size_t retry = 0; retry < MAXIMUM_MAP_RETRIES; retry++) {
auto& page_table{process->PageTable()};
@@ -378,7 +378,7 @@ public:
return ERROR_INSUFFICIENT_ADDRESS_SPACE;
}
- ResultCode LoadNro(Kernel::Process* process, const NROHeader& nro_header, VAddr nro_addr,
+ ResultCode LoadNro(Kernel::KProcess* process, const NROHeader& nro_header, VAddr nro_addr,
VAddr start) const {
const VAddr text_start{start + nro_header.segment_headers[TEXT_INDEX].memory_offset};
const VAddr ro_start{start + nro_header.segment_headers[RO_INDEX].memory_offset};
diff --git a/src/core/hle/service/mm/mm_u.cpp b/src/core/hle/service/mm/mm_u.cpp
index b0cb07d24..c8519e2db 100644
--- a/src/core/hle/service/mm/mm_u.cpp
+++ b/src/core/hle/service/mm/mm_u.cpp
@@ -4,7 +4,6 @@
#include "common/logging/log.h"
#include "core/hle/ipc_helpers.h"
-#include "core/hle/kernel/client_session.h"
#include "core/hle/service/mm/mm_u.h"
#include "core/hle/service/sm/sm.h"
diff --git a/src/core/hle/service/nfp/nfp.cpp b/src/core/hle/service/nfp/nfp.cpp
index 2d1d4d67f..d25b20ab5 100644
--- a/src/core/hle/service/nfp/nfp.cpp
+++ b/src/core/hle/service/nfp/nfp.cpp
@@ -8,7 +8,6 @@
#include "common/logging/log.h"
#include "core/core.h"
#include "core/hle/ipc_helpers.h"
-#include "core/hle/kernel/k_event.h"
#include "core/hle/kernel/k_readable_event.h"
#include "core/hle/kernel/k_thread.h"
#include "core/hle/kernel/k_writable_event.h"
@@ -24,10 +23,9 @@ constexpr ResultCode ERR_NO_APPLICATION_AREA(ErrorModule::NFP, 152);
Module::Interface::Interface(std::shared_ptr<Module> module_, Core::System& system_,
const char* name)
- : ServiceFramework{system_, name}, module{std::move(module_)} {
- auto& kernel = system.Kernel();
- nfc_tag_load = Kernel::KEvent::Create(kernel, "IUser:NFCTagDetected");
- nfc_tag_load->Initialize();
+ : ServiceFramework{system_, name}, nfc_tag_load{system.Kernel()}, module{std::move(module_)} {
+ Kernel::KAutoObject::Create(std::addressof(nfc_tag_load));
+ nfc_tag_load.Initialize("IUser:NFCTagDetected");
}
Module::Interface::~Interface() = default;
@@ -35,7 +33,8 @@ Module::Interface::~Interface() = default;
class IUser final : public ServiceFramework<IUser> {
public:
explicit IUser(Module::Interface& nfp_interface_, Core::System& system_)
- : ServiceFramework{system_, "NFP::IUser"}, nfp_interface{nfp_interface_} {
+ : ServiceFramework{system_, "NFP::IUser"}, nfp_interface{nfp_interface_},
+ deactivate_event{system.Kernel()}, availability_change_event{system.Kernel()} {
static const FunctionInfo functions[] = {
{0, &IUser::Initialize, "Initialize"},
{1, &IUser::Finalize, "Finalize"},
@@ -65,11 +64,11 @@ public:
};
RegisterHandlers(functions);
- auto& kernel = system.Kernel();
- deactivate_event = Kernel::KEvent::Create(kernel, "IUser:DeactivateEvent");
- deactivate_event->Initialize();
- availability_change_event = Kernel::KEvent::Create(kernel, "IUser:AvailabilityChangeEvent");
- availability_change_event->Initialize();
+ Kernel::KAutoObject::Create(std::addressof(deactivate_event));
+ Kernel::KAutoObject::Create(std::addressof(availability_change_event));
+
+ deactivate_event.Initialize("IUser:DeactivateEvent");
+ availability_change_event.Initialize("IUser:AvailabilityChangeEvent");
}
private:
@@ -167,7 +166,7 @@ private:
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(deactivate_event->GetReadableEvent());
+ rb.PushCopyObjects(deactivate_event.GetReadableEvent());
}
void StopDetection(Kernel::HLERequestContext& ctx) {
@@ -176,7 +175,7 @@ private:
switch (device_state) {
case DeviceState::TagFound:
case DeviceState::TagNearby:
- deactivate_event->GetWritableEvent()->Signal();
+ deactivate_event.GetWritableEvent().Signal();
device_state = DeviceState::Initialized;
break;
case DeviceState::SearchingForTag:
@@ -265,7 +264,7 @@ private:
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(availability_change_event->GetReadableEvent());
+ rb.PushCopyObjects(availability_change_event.GetReadableEvent());
}
void GetRegisterInfo(Kernel::HLERequestContext& ctx) {
@@ -319,9 +318,9 @@ private:
const u32 npad_id{0}; // Player 1 controller
State state{State::NonInitialized};
DeviceState device_state{DeviceState::Initialized};
- std::shared_ptr<Kernel::KEvent> deactivate_event;
- std::shared_ptr<Kernel::KEvent> availability_change_event;
- const Module::Interface& nfp_interface;
+ Module::Interface& nfp_interface;
+ Kernel::KEvent deactivate_event;
+ Kernel::KEvent availability_change_event;
};
void Module::Interface::CreateUserInterface(Kernel::HLERequestContext& ctx) {
@@ -339,12 +338,12 @@ bool Module::Interface::LoadAmiibo(const std::vector<u8>& buffer) {
}
std::memcpy(&amiibo, buffer.data(), sizeof(amiibo));
- nfc_tag_load->GetWritableEvent()->Signal();
+ nfc_tag_load.GetWritableEvent().Signal();
return true;
}
-const std::shared_ptr<Kernel::KReadableEvent>& Module::Interface::GetNFCEvent() const {
- return nfc_tag_load->GetReadableEvent();
+Kernel::KReadableEvent& Module::Interface::GetNFCEvent() {
+ return nfc_tag_load.GetReadableEvent();
}
const Module::Interface::AmiiboFile& Module::Interface::GetAmiiboBuffer() const {
diff --git a/src/core/hle/service/nfp/nfp.h b/src/core/hle/service/nfp/nfp.h
index c46551760..5e4e49bc6 100644
--- a/src/core/hle/service/nfp/nfp.h
+++ b/src/core/hle/service/nfp/nfp.h
@@ -7,6 +7,7 @@
#include <array>
#include <vector>
+#include "core/hle/kernel/k_event.h"
#include "core/hle/service/service.h"
namespace Kernel {
@@ -38,11 +39,11 @@ public:
void CreateUserInterface(Kernel::HLERequestContext& ctx);
bool LoadAmiibo(const std::vector<u8>& buffer);
- const std::shared_ptr<Kernel::KReadableEvent>& GetNFCEvent() const;
+ Kernel::KReadableEvent& GetNFCEvent();
const AmiiboFile& GetAmiiboBuffer() const;
private:
- std::shared_ptr<Kernel::KEvent> nfc_tag_load;
+ Kernel::KEvent nfc_tag_load;
AmiiboFile amiibo{};
protected:
diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp
index 9f110df8e..94ef3983a 100644
--- a/src/core/hle/service/nifm/nifm.cpp
+++ b/src/core/hle/service/nifm/nifm.cpp
@@ -127,7 +127,8 @@ public:
class IRequest final : public ServiceFramework<IRequest> {
public:
- explicit IRequest(Core::System& system_) : ServiceFramework{system_, "IRequest"} {
+ explicit IRequest(Core::System& system_)
+ : ServiceFramework{system_, "IRequest"}, event1{system.Kernel()}, event2{system.Kernel()} {
static const FunctionInfo functions[] = {
{0, &IRequest::GetRequestState, "GetRequestState"},
{1, &IRequest::GetResult, "GetResult"},
@@ -157,12 +158,11 @@ public:
};
RegisterHandlers(functions);
- auto& kernel = system.Kernel();
+ Kernel::KAutoObject::Create(std::addressof(event1));
+ Kernel::KAutoObject::Create(std::addressof(event2));
- event1 = Kernel::KEvent::Create(kernel, "IRequest:Event1");
- event1->Initialize();
- event2 = Kernel::KEvent::Create(kernel, "IRequest:Event2");
- event2->Initialize();
+ event1.Initialize("IRequest:Event1");
+ event2.Initialize("IRequest:Event2");
}
private:
@@ -198,7 +198,7 @@ private:
IPC::ResponseBuilder rb{ctx, 2, 2};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(event1->GetReadableEvent(), event2->GetReadableEvent());
+ rb.PushCopyObjects(event1.GetReadableEvent(), event2.GetReadableEvent());
}
void Cancel(Kernel::HLERequestContext& ctx) {
@@ -229,7 +229,7 @@ private:
rb.Push<u32>(0);
}
- std::shared_ptr<Kernel::KEvent> event1, event2;
+ Kernel::KEvent event1, event2;
};
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..420a5a075 100644
--- a/src/core/hle/service/nim/nim.cpp
+++ b/src/core/hle/service/nim/nim.cpp
@@ -300,7 +300,8 @@ class IEnsureNetworkClockAvailabilityService final
: public ServiceFramework<IEnsureNetworkClockAvailabilityService> {
public:
explicit IEnsureNetworkClockAvailabilityService(Core::System& system_)
- : ServiceFramework{system_, "IEnsureNetworkClockAvailabilityService"} {
+ : ServiceFramework{system_, "IEnsureNetworkClockAvailabilityService"},
+ finished_event{system.Kernel()} {
static const FunctionInfo functions[] = {
{0, &IEnsureNetworkClockAvailabilityService::StartTask, "StartTask"},
{1, &IEnsureNetworkClockAvailabilityService::GetFinishNotificationEvent,
@@ -312,19 +313,17 @@ public:
};
RegisterHandlers(functions);
- auto& kernel = system.Kernel();
- finished_event =
- Kernel::KEvent::Create(kernel, "IEnsureNetworkClockAvailabilityService:FinishEvent");
- finished_event->Initialize();
+ Kernel::KAutoObject::Create(std::addressof(finished_event));
+ finished_event.Initialize("IEnsureNetworkClockAvailabilityService:FinishEvent");
}
private:
- std::shared_ptr<Kernel::KEvent> finished_event;
+ Kernel::KEvent finished_event;
void StartTask(Kernel::HLERequestContext& ctx) {
// No need to connect to the internet, just finish the task straight away.
LOG_DEBUG(Service_NIM, "called");
- finished_event->GetWritableEvent()->Signal();
+ finished_event.GetWritableEvent().Signal();
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS);
}
@@ -334,7 +333,7 @@ private:
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(finished_event->GetReadableEvent());
+ rb.PushCopyObjects(finished_event.GetReadableEvent());
}
void GetResult(Kernel::HLERequestContext& ctx) {
@@ -346,7 +345,7 @@ private:
void Cancel(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_NIM, "called");
- finished_event->GetWritableEvent()->Clear();
+ finished_event.GetWritableEvent().Clear();
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS);
}
diff --git a/src/core/hle/service/ns/pl_u.cpp b/src/core/hle/service/ns/pl_u.cpp
index da139fdc4..e14acce58 100644
--- a/src/core/hle/service/ns/pl_u.cpp
+++ b/src/core/hle/service/ns/pl_u.cpp
@@ -130,9 +130,6 @@ struct PL_U::Impl {
}
}
- /// Handle to shared memory region designated for a shared font
- std::shared_ptr<Kernel::KSharedMemory> shared_font_mem;
-
/// Backing memory for the shared font data
std::shared_ptr<Kernel::PhysicalMemory> shared_font;
@@ -260,14 +257,13 @@ void PL_U::GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx) {
// Create shared font memory object
auto& kernel = system.Kernel();
- impl->shared_font_mem = SharedFrom(&kernel.GetFontSharedMem());
- std::memcpy(impl->shared_font_mem->GetPointer(), impl->shared_font->data(),
+ std::memcpy(kernel.GetFontSharedMem().GetPointer(), impl->shared_font->data(),
impl->shared_font->size());
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(impl->shared_font_mem);
+ rb.PushCopyObjects(&kernel.GetFontSharedMem());
}
void PL_U::GetSharedFontInOrderOfPriority(Kernel::HLERequestContext& ctx) {
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
index 6f4007294..775e76330 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
@@ -102,20 +102,20 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector
return NvResult::Success;
}
- auto event = events_interface.events[event_id];
+ auto& event = events_interface.events[event_id];
auto& gpu = system.GPU();
// This is mostly to take into account unimplemented features. As synced
// gpu is always synced.
if (!gpu.IsAsync()) {
- event.event->GetWritableEvent()->Signal();
+ event.event->GetWritableEvent().Signal();
return NvResult::Success;
}
auto lock = gpu.LockSync();
const u32 current_syncpoint_value = event.fence.value;
const s32 diff = current_syncpoint_value - params.threshold;
if (diff >= 0) {
- event.event->GetWritableEvent()->Signal();
+ event.event->GetWritableEvent().Signal();
params.value = current_syncpoint_value;
std::memcpy(output.data(), &params, sizeof(params));
return NvResult::Success;
@@ -142,7 +142,7 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector
params.value = ((params.syncpt_id & 0xfff) << 16) | 0x10000000;
}
params.value |= event_id;
- event.event->GetWritableEvent()->Clear();
+ event.event->GetWritableEvent().Clear();
gpu.RegisterSyncptInterrupt(params.syncpt_id, target_value);
std::memcpy(output.data(), &params, sizeof(params));
return NvResult::Timeout;
diff --git a/src/core/hle/service/nvdrv/interface.cpp b/src/core/hle/service/nvdrv/interface.cpp
index eff9c3cc9..dc9b9341f 100644
--- a/src/core/hle/service/nvdrv/interface.cpp
+++ b/src/core/hle/service/nvdrv/interface.cpp
@@ -187,8 +187,8 @@ void NVDRV::QueryEvent(Kernel::HLERequestContext& ctx) {
if (event_id < MaxNvEvents) {
IPC::ResponseBuilder rb{ctx, 3, 1};
rb.Push(RESULT_SUCCESS);
- auto event = nvdrv->GetEvent(event_id);
- event->Clear();
+ auto& event = nvdrv->GetEvent(event_id);
+ event.Clear();
rb.PushCopyObjects(event);
rb.PushEnum(NvResult::Success);
} else {
diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp
index ede77858a..74796dce1 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
Module::Module(Core::System& system) : syncpoint_manager{system.GPU()} {
auto& kernel = system.Kernel();
for (u32 i = 0; i < MaxNvEvents; i++) {
- std::string event_label = fmt::format("NVDRV::NvEvent_{}", i);
- events_interface.events[i] = {Kernel::KEvent::Create(kernel, std::move(event_label))};
- events_interface.events[i].event->Initialize();
+ events_interface.events[i].event = Kernel::KEvent::Create(kernel);
+ events_interface.events[i].event->Initialize(fmt::format("NVDRV::NvEvent_{}", i));
events_interface.status[i] = EventState::Free;
events_interface.registered[i] = false;
}
@@ -64,7 +63,12 @@ Module::Module(Core::System& system) : syncpoint_manager{system.GPU()} {
std::make_shared<Devices::nvhost_vic>(system, nvmap_dev, syncpoint_manager);
}
-Module::~Module() = default;
+Module::~Module() {
+ for (u32 i = 0; i < MaxNvEvents; i++) {
+ events_interface.events[i].event->Close();
+ events_interface.events[i].event = nullptr;
+ }
+}
NvResult Module::VerifyFD(DeviceFD fd) const {
if (fd < 0) {
@@ -172,16 +176,16 @@ void Module::SignalSyncpt(const u32 syncpoint_id, const u32 value) {
if (events_interface.assigned_syncpt[i] == syncpoint_id &&
events_interface.assigned_value[i] == value) {
events_interface.LiberateEvent(i);
- events_interface.events[i].event->GetWritableEvent()->Signal();
+ events_interface.events[i].event->GetWritableEvent().Signal();
}
}
}
-std::shared_ptr<Kernel::KReadableEvent> Module::GetEvent(const u32 event_id) const {
+Kernel::KReadableEvent& Module::GetEvent(const u32 event_id) {
return events_interface.events[event_id].event->GetReadableEvent();
}
-std::shared_ptr<Kernel::KWritableEvent> Module::GetEventWriteable(const u32 event_id) const {
+Kernel::KWritableEvent& Module::GetEventWriteable(const u32 event_id) {
return events_interface.events[event_id].event->GetWritableEvent();
}
diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h
index 53719aadd..a43ceb7ae 100644
--- a/src/core/hle/service/nvdrv/nvdrv.h
+++ b/src/core/hle/service/nvdrv/nvdrv.h
@@ -35,7 +35,7 @@ class nvdevice;
/// Represents an Nvidia event
struct NvEvent {
- std::shared_ptr<Kernel::KEvent> event;
+ Kernel::KEvent* event{};
Fence fence{};
};
@@ -136,9 +136,9 @@ public:
void SignalSyncpt(const u32 syncpoint_id, const u32 value);
- std::shared_ptr<Kernel::KReadableEvent> GetEvent(u32 event_id) const;
+ Kernel::KReadableEvent& GetEvent(u32 event_id);
- std::shared_ptr<Kernel::KWritableEvent> GetEventWriteable(u32 event_id) const;
+ Kernel::KWritableEvent& GetEventWriteable(u32 event_id);
private:
/// Manages syncpoints on the host
diff --git a/src/core/hle/service/nvflinger/buffer_queue.cpp b/src/core/hle/service/nvflinger/buffer_queue.cpp
index 7842a82ed..0b6e7430b 100644
--- a/src/core/hle/service/nvflinger/buffer_queue.cpp
+++ b/src/core/hle/service/nvflinger/buffer_queue.cpp
@@ -7,7 +7,6 @@
#include "common/assert.h"
#include "common/logging/log.h"
#include "core/core.h"
-#include "core/hle/kernel/k_event.h"
#include "core/hle/kernel/k_writable_event.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/service/nvflinger/buffer_queue.h"
@@ -15,9 +14,9 @@
namespace Service::NVFlinger {
BufferQueue::BufferQueue(Kernel::KernelCore& kernel, u32 id, u64 layer_id)
- : id(id), layer_id(layer_id) {
- buffer_wait_event = Kernel::KEvent::Create(kernel, "BufferQueue:WaitEvent");
- buffer_wait_event->Initialize();
+ : id(id), layer_id(layer_id), buffer_wait_event{kernel} {
+ Kernel::KAutoObject::Create(std::addressof(buffer_wait_event));
+ buffer_wait_event.Initialize("BufferQueue:WaitEvent");
}
BufferQueue::~BufferQueue() = default;
@@ -42,7 +41,7 @@ void BufferQueue::SetPreallocatedBuffer(u32 slot, const IGBPBuffer& igbp_buffer)
.multi_fence = {},
};
- buffer_wait_event->GetWritableEvent()->Signal();
+ buffer_wait_event.GetWritableEvent().Signal();
}
std::optional<std::pair<u32, Service::Nvidia::MultiFence*>> BufferQueue::DequeueBuffer(u32 width,
@@ -120,7 +119,7 @@ void BufferQueue::CancelBuffer(u32 slot, const Service::Nvidia::MultiFence& mult
}
free_buffers_condition.notify_one();
- buffer_wait_event->GetWritableEvent()->Signal();
+ buffer_wait_event.GetWritableEvent().Signal();
}
std::optional<std::reference_wrapper<const BufferQueue::Buffer>> BufferQueue::AcquireBuffer() {
@@ -155,7 +154,7 @@ void BufferQueue::ReleaseBuffer(u32 slot) {
}
free_buffers_condition.notify_one();
- buffer_wait_event->GetWritableEvent()->Signal();
+ buffer_wait_event.GetWritableEvent().Signal();
}
void BufferQueue::Connect() {
@@ -170,7 +169,7 @@ void BufferQueue::Disconnect() {
std::unique_lock lock{queue_sequence_mutex};
queue_sequence.clear();
}
- buffer_wait_event->GetWritableEvent()->Signal();
+ buffer_wait_event.GetWritableEvent().Signal();
is_connect = false;
free_buffers_condition.notify_one();
}
@@ -189,12 +188,12 @@ u32 BufferQueue::Query(QueryType type) {
return 0;
}
-std::shared_ptr<Kernel::KWritableEvent> BufferQueue::GetWritableBufferWaitEvent() const {
- return buffer_wait_event->GetWritableEvent();
+Kernel::KWritableEvent& BufferQueue::GetWritableBufferWaitEvent() {
+ return buffer_wait_event.GetWritableEvent();
}
-std::shared_ptr<Kernel::KReadableEvent> BufferQueue::GetBufferWaitEvent() const {
- return buffer_wait_event->GetReadableEvent();
+Kernel::KReadableEvent& BufferQueue::GetBufferWaitEvent() {
+ return buffer_wait_event.GetReadableEvent();
}
} // namespace Service::NVFlinger
diff --git a/src/core/hle/service/nvflinger/buffer_queue.h b/src/core/hle/service/nvflinger/buffer_queue.h
index 163fa4c54..4ec0b1506 100644
--- a/src/core/hle/service/nvflinger/buffer_queue.h
+++ b/src/core/hle/service/nvflinger/buffer_queue.h
@@ -13,7 +13,8 @@
#include "common/common_funcs.h"
#include "common/math_util.h"
#include "common/swap.h"
-#include "core/hle/kernel/object.h"
+#include "core/hle/kernel/k_event.h"
+#include "core/hle/kernel/k_readable_event.h"
#include "core/hle/service/nvdrv/nvdata.h"
namespace Kernel {
@@ -115,9 +116,9 @@ public:
return is_connect;
}
- std::shared_ptr<Kernel::KWritableEvent> GetWritableBufferWaitEvent() const;
+ Kernel::KWritableEvent& GetWritableBufferWaitEvent();
- std::shared_ptr<Kernel::KReadableEvent> GetBufferWaitEvent() const;
+ Kernel::KReadableEvent& GetBufferWaitEvent();
private:
BufferQueue(const BufferQueue&) = delete;
@@ -129,7 +130,7 @@ private:
std::list<u32> free_buffers;
std::array<Buffer, buffer_slots> buffers;
std::list<u32> queue_sequence;
- std::shared_ptr<Kernel::KEvent> buffer_wait_event;
+ Kernel::KEvent buffer_wait_event;
std::mutex free_buffers_mutex;
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..7fb9133c7 100644
--- a/src/core/hle/service/nvflinger/nvflinger.cpp
+++ b/src/core/hle/service/nvflinger/nvflinger.cpp
@@ -165,7 +165,7 @@ std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) co
return layer->GetBufferQueue().GetId();
}
-std::shared_ptr<Kernel::KReadableEvent> NVFlinger::FindVsyncEvent(u64 display_id) const {
+Kernel::KReadableEvent* NVFlinger::FindVsyncEvent(u64 display_id) {
const auto lock_guard = Lock();
auto* const display = FindDisplay(display_id);
@@ -173,7 +173,7 @@ std::shared_ptr<Kernel::KReadableEvent> NVFlinger::FindVsyncEvent(u64 display_id
return nullptr;
}
- return display->GetVSyncEvent();
+ return &display->GetVSyncEvent();
}
BufferQueue* NVFlinger::FindBufferQueue(u32 id) {
diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h
index 6fe2c7f2a..b0febdaec 100644
--- a/src/core/hle/service/nvflinger/nvflinger.h
+++ b/src/core/hle/service/nvflinger/nvflinger.h
@@ -5,6 +5,7 @@
#pragma once
#include <atomic>
+#include <list>
#include <memory>
#include <mutex>
#include <optional>
@@ -14,7 +15,6 @@
#include <vector>
#include "common/common_types.h"
-#include "core/hle/kernel/object.h"
namespace Common {
class Event;
@@ -72,7 +72,7 @@ public:
/// Gets the vsync event for the specified display.
///
/// If an invalid display ID is provided, then nullptr is returned.
- [[nodiscard]] std::shared_ptr<Kernel::KReadableEvent> FindVsyncEvent(u64 display_id) const;
+ [[nodiscard]] Kernel::KReadableEvent* FindVsyncEvent(u64 display_id);
/// Obtains a buffer queue identified by the ID.
[[nodiscard]] BufferQueue* FindBufferQueue(u32 id);
@@ -106,7 +106,7 @@ private:
std::shared_ptr<Nvidia::Module> nvdrv;
- std::vector<VI::Display> displays;
+ std::list<VI::Display> displays;
std::vector<std::unique_ptr<BufferQueue>> buffer_queues;
/// Id to use for the next layer that is created, this counter is shared among all displays.
diff --git a/src/core/hle/service/pctl/module.cpp b/src/core/hle/service/pctl/module.cpp
index 9bebe6088..1c3d81143 100644
--- a/src/core/hle/service/pctl/module.cpp
+++ b/src/core/hle/service/pctl/module.cpp
@@ -7,7 +7,7 @@
#include "core/file_sys/control_metadata.h"
#include "core/file_sys/patch_manager.h"
#include "core/hle/ipc_helpers.h"
-#include "core/hle/kernel/process.h"
+#include "core/hle/kernel/k_process.h"
#include "core/hle/service/pctl/module.h"
#include "core/hle/service/pctl/pctl.h"
diff --git a/src/core/hle/service/pm/pm.cpp b/src/core/hle/service/pm/pm.cpp
index 68736c40c..f4715935d 100644
--- a/src/core/hle/service/pm/pm.cpp
+++ b/src/core/hle/service/pm/pm.cpp
@@ -4,8 +4,8 @@
#include "core/core.h"
#include "core/hle/ipc_helpers.h"
+#include "core/hle/kernel/k_process.h"
#include "core/hle/kernel/kernel.h"
-#include "core/hle/kernel/process.h"
#include "core/hle/service/pm/pm.h"
#include "core/hle/service/service.h"
@@ -17,9 +17,9 @@ constexpr ResultCode ERROR_PROCESS_NOT_FOUND{ErrorModule::PM, 1};
constexpr u64 NO_PROCESS_FOUND_PID{0};
-std::optional<std::shared_ptr<Kernel::Process>> SearchProcessList(
- const std::vector<std::shared_ptr<Kernel::Process>>& process_list,
- std::function<bool(const std::shared_ptr<Kernel::Process>&)> predicate) {
+std::optional<Kernel::KProcess*> SearchProcessList(
+ const std::vector<Kernel::KProcess*>& process_list,
+ std::function<bool(Kernel::KProcess*)> predicate) {
const auto iter = std::find_if(process_list.begin(), process_list.end(), predicate);
if (iter == process_list.end()) {
@@ -30,9 +30,9 @@ std::optional<std::shared_ptr<Kernel::Process>> SearchProcessList(
}
void GetApplicationPidGeneric(Kernel::HLERequestContext& ctx,
- const std::vector<std::shared_ptr<Kernel::Process>>& process_list) {
+ const std::vector<Kernel::KProcess*>& process_list) {
const auto process = SearchProcessList(process_list, [](const auto& process) {
- return process->GetProcessID() == Kernel::Process::ProcessIDMin;
+ return process->GetProcessID() == Kernel::KProcess::ProcessIDMin;
});
IPC::ResponseBuilder rb{ctx, 4};
@@ -125,8 +125,7 @@ private:
class Info final : public ServiceFramework<Info> {
public:
- explicit Info(Core::System& system_,
- const std::vector<std::shared_ptr<Kernel::Process>>& process_list_)
+ explicit Info(Core::System& system_, const std::vector<Kernel::KProcess*>& process_list_)
: ServiceFramework{system_, "pm:info"}, process_list{process_list_} {
static const FunctionInfo functions[] = {
{0, &Info::GetTitleId, "GetTitleId"},
@@ -156,7 +155,7 @@ private:
rb.Push((*process)->GetTitleID());
}
- const std::vector<std::shared_ptr<Kernel::Process>>& process_list;
+ const std::vector<Kernel::KProcess*>& process_list;
};
class Shell final : public ServiceFramework<Shell> {
diff --git a/src/core/hle/service/prepo/prepo.cpp b/src/core/hle/service/prepo/prepo.cpp
index d5b3b17a5..c914f8145 100644
--- a/src/core/hle/service/prepo/prepo.cpp
+++ b/src/core/hle/service/prepo/prepo.cpp
@@ -6,7 +6,7 @@
#include "common/logging/log.h"
#include "core/core.h"
#include "core/hle/ipc_helpers.h"
-#include "core/hle/kernel/process.h"
+#include "core/hle/kernel/k_process.h"
#include "core/hle/service/acc/profile_manager.h"
#include "core/hle/service/prepo/prepo.h"
#include "core/hle/service/service.h"
@@ -60,7 +60,7 @@ private:
const auto process_id = rp.PopRaw<u64>();
const auto data1 = ctx.ReadBuffer(0);
- const auto data2 = [ctx] {
+ const auto data2 = [&ctx] {
if (ctx.CanReadBuffer(1)) {
return ctx.ReadBuffer(1);
}
@@ -87,7 +87,7 @@ private:
const auto process_id = rp.PopRaw<u64>();
const auto data1 = ctx.ReadBuffer(0);
- const auto data2 = [ctx] {
+ const auto data2 = [&ctx] {
if (ctx.CanReadBuffer(1)) {
return ctx.ReadBuffer(1);
}
@@ -139,7 +139,7 @@ private:
const auto title_id = rp.PopRaw<u64>();
const auto data1 = ctx.ReadBuffer(0);
- const auto data2 = [ctx] {
+ const auto data2 = [&ctx] {
if (ctx.CanReadBuffer(1)) {
return ctx.ReadBuffer(1);
}
@@ -163,7 +163,7 @@ private:
const auto title_id = rp.PopRaw<u64>();
const auto data1 = ctx.ReadBuffer(0);
- const auto data2 = [ctx] {
+ const auto data2 = [&ctx] {
if (ctx.CanReadBuffer(1)) {
return ctx.ReadBuffer(1);
}
diff --git a/src/core/hle/service/ptm/psm.cpp b/src/core/hle/service/ptm/psm.cpp
index 26ed52273..bb7af9217 100644
--- a/src/core/hle/service/ptm/psm.cpp
+++ b/src/core/hle/service/ptm/psm.cpp
@@ -19,7 +19,8 @@ namespace Service::PSM {
class IPsmSession final : public ServiceFramework<IPsmSession> {
public:
- explicit IPsmSession(Core::System& system_) : ServiceFramework{system_, "IPsmSession"} {
+ explicit IPsmSession(Core::System& system_)
+ : ServiceFramework{system_, "IPsmSession"}, state_change_event{system.Kernel()} {
// clang-format off
static const FunctionInfo functions[] = {
{0, &IPsmSession::BindStateChangeEvent, "BindStateChangeEvent"},
@@ -32,28 +33,27 @@ public:
RegisterHandlers(functions);
- state_change_event =
- Kernel::KEvent::Create(system_.Kernel(), "IPsmSession::state_change_event");
- state_change_event->Initialize();
+ Kernel::KAutoObject::Create(std::addressof(state_change_event));
+ state_change_event.Initialize("IPsmSession::state_change_event");
}
~IPsmSession() override = default;
void SignalChargerTypeChanged() {
if (should_signal && should_signal_charger_type) {
- state_change_event->GetWritableEvent()->Signal();
+ state_change_event.GetWritableEvent().Signal();
}
}
void SignalPowerSupplyChanged() {
if (should_signal && should_signal_power_supply) {
- state_change_event->GetWritableEvent()->Signal();
+ state_change_event.GetWritableEvent().Signal();
}
}
void SignalBatteryVoltageStateChanged() {
if (should_signal && should_signal_battery_voltage) {
- state_change_event->GetWritableEvent()->Signal();
+ state_change_event.GetWritableEvent().Signal();
}
}
@@ -65,7 +65,7 @@ private:
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(state_change_event->GetReadableEvent());
+ rb.PushCopyObjects(state_change_event.GetReadableEvent());
}
void UnbindStateChangeEvent(Kernel::HLERequestContext& ctx) {
@@ -114,7 +114,7 @@ private:
bool should_signal_power_supply{};
bool should_signal_battery_voltage{};
bool should_signal{};
- std::shared_ptr<Kernel::KEvent> state_change_event;
+ Kernel::KEvent state_change_event;
};
class PSM final : public ServiceFramework<PSM> {
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index 41a502d8d..00e683c2f 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -11,11 +11,11 @@
#include "core/core.h"
#include "core/hle/ipc.h"
#include "core/hle/ipc_helpers.h"
-#include "core/hle/kernel/client_port.h"
+#include "core/hle/kernel/k_client_port.h"
+#include "core/hle/kernel/k_process.h"
+#include "core/hle/kernel/k_server_port.h"
#include "core/hle/kernel/k_thread.h"
#include "core/hle/kernel/kernel.h"
-#include "core/hle/kernel/process.h"
-#include "core/hle/kernel/server_port.h"
#include "core/hle/service/acc/acc.h"
#include "core/hle/service/am/am.h"
#include "core/hle/service/aoc/aoc_u.h"
@@ -116,10 +116,11 @@ void ServiceFrameworkBase::InstallAsNamedPort(Kernel::KernelCore& kernel) {
ASSERT(!port_installed);
- auto [server_port, client_port] =
- Kernel::ServerPort::CreatePortPair(kernel, max_sessions, service_name);
- server_port->SetHleHandler(shared_from_this());
- kernel.AddNamedPort(service_name, std::move(client_port));
+ auto* port = Kernel::KPort::Create(kernel);
+ port->Initialize(max_sessions, false, service_name);
+ port->GetServerPort().SetHleHandler(shared_from_this());
+ kernel.AddNamedPort(service_name, &port->GetClientPort());
+
port_installed = true;
}
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h
index 916445517..884951428 100644
--- a/src/core/hle/service/service.h
+++ b/src/core/hle/service/service.h
@@ -11,7 +11,6 @@
#include "common/common_types.h"
#include "common/spin_lock.h"
#include "core/hle/kernel/hle_ipc.h"
-#include "core/hle/kernel/object.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
// Namespace Service
@@ -21,11 +20,8 @@ class System;
}
namespace Kernel {
-class ClientPort;
-class ServerPort;
-class ServerSession;
class HLERequestContext;
-} // namespace Kernel
+}
namespace Service {
diff --git a/src/core/hle/service/set/set_sys.cpp b/src/core/hle/service/set/set_sys.cpp
index 5909fdd85..4f1ffe55f 100644
--- a/src/core/hle/service/set/set_sys.cpp
+++ b/src/core/hle/service/set/set_sys.cpp
@@ -7,7 +7,7 @@
#include "core/file_sys/errors.h"
#include "core/file_sys/system_archive/system_version.h"
#include "core/hle/ipc_helpers.h"
-#include "core/hle/kernel/client_port.h"
+#include "core/hle/kernel/k_client_port.h"
#include "core/hle/service/filesystem/filesystem.h"
#include "core/hle/service/set/set_sys.h"
diff --git a/src/core/hle/service/sm/controller.cpp b/src/core/hle/service/sm/controller.cpp
index 916177efd..ee026e22f 100644
--- a/src/core/hle/service/sm/controller.cpp
+++ b/src/core/hle/service/sm/controller.cpp
@@ -5,16 +5,16 @@
#include "common/assert.h"
#include "common/logging/log.h"
#include "core/hle/ipc_helpers.h"
-#include "core/hle/kernel/client_session.h"
-#include "core/hle/kernel/server_session.h"
-#include "core/hle/kernel/session.h"
+#include "core/hle/kernel/k_client_session.h"
+#include "core/hle/kernel/k_server_session.h"
+#include "core/hle/kernel/k_session.h"
#include "core/hle/service/sm/controller.h"
namespace Service::SM {
void Controller::ConvertCurrentObjectToDomain(Kernel::HLERequestContext& ctx) {
ASSERT_MSG(ctx.Session()->IsSession(), "Session is already a domain");
- LOG_DEBUG(Service, "called, server_session={}", ctx.Session()->GetObjectId());
+ LOG_DEBUG(Service, "called, server_session={}", ctx.Session()->GetId());
ctx.Session()->ConvertToDomain();
IPC::ResponseBuilder rb{ctx, 3};
@@ -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()->GetClientSession());
}
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..568effbc9 100644
--- a/src/core/hle/service/sm/sm.cpp
+++ b/src/core/hle/service/sm/sm.cpp
@@ -6,9 +6,12 @@
#include "common/assert.h"
#include "core/core.h"
#include "core/hle/ipc_helpers.h"
-#include "core/hle/kernel/client_port.h"
-#include "core/hle/kernel/client_session.h"
-#include "core/hle/kernel/server_port.h"
+#include "core/hle/kernel/k_client_port.h"
+#include "core/hle/kernel/k_client_session.h"
+#include "core/hle/kernel/k_port.h"
+#include "core/hle/kernel/k_server_port.h"
+#include "core/hle/kernel/k_server_session.h"
+#include "core/hle/kernel/k_session.h"
#include "core/hle/result.h"
#include "core/hle/service/sm/controller.h"
#include "core/hle/service/sm/sm.h"
@@ -47,8 +50,8 @@ void ServiceManager::InstallInterfaces(std::shared_ptr<ServiceManager> self, Cor
self->controller_interface = std::make_unique<Controller>(system);
}
-ResultVal<std::shared_ptr<Kernel::ServerPort>> ServiceManager::RegisterService(std::string name,
- u32 max_sessions) {
+ResultVal<Kernel::KServerPort*> ServiceManager::RegisterService(std::string name,
+ u32 max_sessions) {
CASCADE_CODE(ValidateServiceName(name));
@@ -57,11 +60,12 @@ ResultVal<std::shared_ptr<Kernel::ServerPort>> ServiceManager::RegisterService(s
return ERR_ALREADY_REGISTERED;
}
- auto [server_port, client_port] =
- Kernel::ServerPort::CreatePortPair(kernel, max_sessions, name);
+ auto* port = Kernel::KPort::Create(kernel);
+ port->Initialize(max_sessions, false, name);
- registered_services.emplace(std::move(name), std::move(client_port));
- return MakeResult(std::move(server_port));
+ registered_services.emplace(std::move(name), port);
+
+ return MakeResult(&port->GetServerPort());
}
ResultCode ServiceManager::UnregisterService(const std::string& name) {
@@ -72,12 +76,14 @@ ResultCode ServiceManager::UnregisterService(const std::string& name) {
LOG_ERROR(Service_SM, "Server is not registered! service={}", name);
return ERR_SERVICE_NOT_REGISTERED;
}
+
+ iter->second->Close();
+
registered_services.erase(iter);
return RESULT_SUCCESS;
}
-ResultVal<std::shared_ptr<Kernel::ClientPort>> ServiceManager::GetServicePort(
- const std::string& name) {
+ResultVal<Kernel::KPort*> ServiceManager::GetServicePort(const std::string& name) {
CASCADE_CODE(ValidateServiceName(name));
auto it = registered_services.find(name);
@@ -89,13 +95,6 @@ ResultVal<std::shared_ptr<Kernel::ClientPort>> ServiceManager::GetServicePort(
return MakeResult(it->second);
}
-ResultVal<std::shared_ptr<Kernel::ClientSession>> ServiceManager::ConnectToService(
- const std::string& name) {
-
- CASCADE_RESULT(auto client_port, GetServicePort(name));
- return client_port->Connect();
-}
-
SM::~SM() = default;
/**
@@ -119,30 +118,32 @@ void SM::GetService(Kernel::HLERequestContext& ctx) {
std::string name(name_buf.begin(), end);
- auto client_port = service_manager->GetServicePort(name);
- if (client_port.Failed()) {
+ auto result = service_manager->GetServicePort(name);
+ if (result.Failed()) {
IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(client_port.Code());
- LOG_ERROR(Service_SM, "called service={} -> error 0x{:08X}", name, client_port.Code().raw);
+ rb.Push(result.Code());
+ LOG_ERROR(Service_SM, "called service={} -> error 0x{:08X}", name, result.Code().raw);
if (name.length() == 0)
return; // LibNX Fix
UNIMPLEMENTED();
return;
}
- auto [client, server] = Kernel::Session::Create(kernel, name);
+ auto* port = result.Unwrap();
- const auto& server_port = client_port.Unwrap()->GetServerPort();
- if (server_port->GetHLEHandler()) {
- server_port->GetHLEHandler()->ClientConnected(server);
+ auto* session = Kernel::KSession::Create(kernel);
+ session->Initialize(&port->GetClientPort(), std::move(name));
+
+ if (port->GetServerPort().GetHLEHandler()) {
+ port->GetServerPort().GetHLEHandler()->ClientConnected(&session->GetServerSession());
} else {
- server_port->AppendPendingSession(server);
+ port->EnqueueSession(&session->GetServerSession());
}
- LOG_DEBUG(Service_SM, "called service={} -> session={}", name, client->GetObjectId());
+ LOG_DEBUG(Service_SM, "called service={} -> session={}", name, session->GetId());
IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles};
rb.Push(RESULT_SUCCESS);
- rb.PushMoveObjects(std::move(client));
+ rb.PushMoveObjects(session->GetClientSession());
}
void SM::RegisterService(Kernel::HLERequestContext& ctx) {
@@ -170,7 +171,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);
}
void SM::UnregisterService(Kernel::HLERequestContext& ctx) {
diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h
index 3f46ae44f..af5010c3b 100644
--- a/src/core/hle/service/sm/sm.h
+++ b/src/core/hle/service/sm/sm.h
@@ -10,9 +10,7 @@
#include <unordered_map>
#include "common/concepts.h"
-#include "core/hle/kernel/client_port.h"
-#include "core/hle/kernel/object.h"
-#include "core/hle/kernel/server_port.h"
+#include "core/hle/kernel/k_port.h"
#include "core/hle/result.h"
#include "core/hle/service/service.h"
@@ -21,10 +19,11 @@ class System;
}
namespace Kernel {
-class ClientPort;
-class ClientSession;
+class KClientPort;
+class KClientSession;
class KernelCore;
-class ServerPort;
+class KPort;
+class KServerPort;
class SessionRequestHandler;
} // namespace Kernel
@@ -55,11 +54,9 @@ public:
explicit ServiceManager(Kernel::KernelCore& kernel_);
~ServiceManager();
- ResultVal<std::shared_ptr<Kernel::ServerPort>> RegisterService(std::string name,
- u32 max_sessions);
+ ResultVal<Kernel::KServerPort*> RegisterService(std::string name, u32 max_sessions);
ResultCode UnregisterService(const std::string& name);
- ResultVal<std::shared_ptr<Kernel::ClientPort>> GetServicePort(const std::string& name);
- ResultVal<std::shared_ptr<Kernel::ClientSession>> ConnectToService(const std::string& name);
+ ResultVal<Kernel::KPort*> GetServicePort(const std::string& name);
template <Common::DerivedFrom<Kernel::SessionRequestHandler> T>
std::shared_ptr<T> GetService(const std::string& service_name) const {
@@ -68,11 +65,11 @@ public:
LOG_DEBUG(Service, "Can't find service: {}", service_name);
return nullptr;
}
- auto port = service->second->GetServerPort();
+ auto* port = service->second;
if (port == nullptr) {
return nullptr;
}
- return std::static_pointer_cast<T>(port->GetHLEHandler());
+ return std::static_pointer_cast<T>(port->GetServerPort().GetHLEHandler());
}
void InvokeControlRequest(Kernel::HLERequestContext& context);
@@ -81,8 +78,8 @@ private:
std::weak_ptr<SM> sm_interface;
std::unique_ptr<Controller> controller_interface;
- /// Map of registered services, retrieved using GetServicePort or ConnectToService.
- std::unordered_map<std::string, std::shared_ptr<Kernel::ClientPort>> registered_services;
+ /// Map of registered services, retrieved using GetServicePort.
+ std::unordered_map<std::string, Kernel::KPort*> registered_services;
/// Kernel context
Kernel::KernelCore& kernel;
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..7f47b12b8 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 @@
#include "common/assert.h"
#include "core/core.h"
-#include "core/hle/kernel/k_event.h"
#include "core/hle/service/time/standard_local_system_clock_core.h"
#include "core/hle/service/time/standard_network_system_clock_core.h"
#include "core/hle/service/time/standard_user_system_clock_core.h"
@@ -17,10 +16,10 @@ StandardUserSystemClockCore::StandardUserSystemClockCore(
: SystemClockCore(local_system_clock_core.GetSteadyClockCore()),
local_system_clock_core{local_system_clock_core},
network_system_clock_core{network_system_clock_core}, auto_correction_enabled{},
- auto_correction_time{SteadyClockTimePoint::GetRandom()},
- auto_correction_event{Kernel::KEvent::Create(
- system.Kernel(), "StandardUserSystemClockCore:AutoCorrectionEvent")} {
- auto_correction_event->Initialize();
+ auto_correction_time{SteadyClockTimePoint::GetRandom()}, auto_correction_event{
+ system.Kernel()} {
+ Kernel::KAutoObject::Create(std::addressof(auto_correction_event));
+ auto_correction_event.Initialize("StandardUserSystemClockCore:AutoCorrectionEvent");
}
ResultCode StandardUserSystemClockCore::SetAutomaticCorrectionEnabled(Core::System& system,
diff --git a/src/core/hle/service/time/standard_user_system_clock_core.h b/src/core/hle/service/time/standard_user_system_clock_core.h
index 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 @@
#pragma once
+#include "core/hle/kernel/k_event.h"
#include "core/hle/service/time/clock_types.h"
#include "core/hle/service/time/system_clock_core.h"
@@ -54,7 +55,7 @@ private:
StandardNetworkSystemClockCore& network_system_clock_core;
bool auto_correction_enabled{};
SteadyClockTimePoint auto_correction_time;
- std::shared_ptr<Kernel::KEvent> auto_correction_event;
+ Kernel::KEvent auto_correction_event;
};
} // namespace Service::Time::Clock
diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp
index 32f372d71..e7991012b 100644
--- a/src/core/hle/service/time/time.cpp
+++ b/src/core/hle/service/time/time.cpp
@@ -8,8 +8,7 @@
#include "core/core_timing_util.h"
#include "core/hardware_properties.h"
#include "core/hle/ipc_helpers.h"
-#include "core/hle/kernel/client_port.h"
-#include "core/hle/kernel/client_session.h"
+#include "core/hle/kernel/k_client_port.h"
#include "core/hle/kernel/k_scheduler.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/service/time/interface.h"
@@ -393,7 +392,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> module_, Core::System& system_,
diff --git a/src/core/hle/service/time/time_sharedmemory.cpp b/src/core/hle/service/time/time_sharedmemory.cpp
index 018ce94ed..eb57899f6 100644
--- a/src/core/hle/service/time/time_sharedmemory.cpp
+++ b/src/core/hle/service/time/time_sharedmemory.cpp
@@ -16,16 +16,11 @@ namespace Service::Time {
static constexpr std::size_t SHARED_MEMORY_SIZE{0x1000};
SharedMemory::SharedMemory(Core::System& system) : system(system) {
- shared_memory_holder = SharedFrom(&system.Kernel().GetTimeSharedMem());
- std::memset(shared_memory_holder->GetPointer(), 0, SHARED_MEMORY_SIZE);
+ std::memset(system.Kernel().GetTimeSharedMem().GetPointer(), 0, SHARED_MEMORY_SIZE);
}
SharedMemory::~SharedMemory() = default;
-std::shared_ptr<Kernel::KSharedMemory> SharedMemory::GetSharedMemoryHolder() const {
- return shared_memory_holder;
-}
-
void SharedMemory::SetupStandardSteadyClock(const Common::UUID& clock_source_id,
Clock::TimeSpanType current_time_point) {
const Clock::TimeSpanType ticks_time_span{Clock::TimeSpanType::FromTicks(
@@ -34,22 +29,22 @@ void SharedMemory::SetupStandardSteadyClock(const Common::UUID& clock_source_id,
static_cast<u64>(current_time_point.nanoseconds - ticks_time_span.nanoseconds),
clock_source_id};
shared_memory_format.standard_steady_clock_timepoint.StoreData(
- shared_memory_holder->GetPointer(), context);
+ system.Kernel().GetTimeSharedMem().GetPointer(), context);
}
void SharedMemory::UpdateLocalSystemClockContext(const Clock::SystemClockContext& context) {
shared_memory_format.standard_local_system_clock_context.StoreData(
- shared_memory_holder->GetPointer(), context);
+ system.Kernel().GetTimeSharedMem().GetPointer(), context);
}
void SharedMemory::UpdateNetworkSystemClockContext(const Clock::SystemClockContext& context) {
shared_memory_format.standard_network_system_clock_context.StoreData(
- shared_memory_holder->GetPointer(), context);
+ system.Kernel().GetTimeSharedMem().GetPointer(), context);
}
void SharedMemory::SetAutomaticCorrectionEnabled(bool is_enabled) {
shared_memory_format.standard_user_system_clock_automatic_correction.StoreData(
- shared_memory_holder->GetPointer(), is_enabled);
+ system.Kernel().GetTimeSharedMem().GetPointer(), is_enabled);
}
} // namespace Service::Time
diff --git a/src/core/hle/service/time/time_sharedmemory.h b/src/core/hle/service/time/time_sharedmemory.h
index 3bc749114..1ad9a286d 100644
--- a/src/core/hle/service/time/time_sharedmemory.h
+++ b/src/core/hle/service/time/time_sharedmemory.h
@@ -17,9 +17,6 @@ public:
explicit SharedMemory(Core::System& system);
~SharedMemory();
- // Return the shared memory handle
- std::shared_ptr<Kernel::KSharedMemory> GetSharedMemoryHolder() const;
-
// TODO(ogniK): We have to properly simulate memory barriers, how are we going to do this?
template <typename T, std::size_t Offset>
struct MemoryBarrier {
@@ -63,7 +60,6 @@ public:
void SetAutomaticCorrectionEnabled(bool is_enabled);
private:
- std::shared_ptr<Kernel::KSharedMemory> shared_memory_holder;
Core::System& system;
Format shared_memory_format{};
};
diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp
index ac9e87338..becbd36c1 100644
--- a/src/core/hle/service/vi/display/vi_display.cpp
+++ b/src/core/hle/service/vi/display/vi_display.cpp
@@ -17,10 +17,10 @@
namespace Service::VI {
-Display::Display(u64 id, std::string name, Core::System& system) : id{id}, name{std::move(name)} {
- auto& kernel = system.Kernel();
- vsync_event = Kernel::KEvent::Create(kernel, fmt::format("Display VSync Event {}", id));
- vsync_event->Initialize();
+Display::Display(u64 id, std::string name, Core::System& system)
+ : id{id}, name{std::move(name)}, vsync_event{system.Kernel()} {
+ Kernel::KAutoObject::Create(std::addressof(vsync_event));
+ vsync_event.Initialize(fmt::format("Display VSync Event {}", id));
}
Display::~Display() = default;
@@ -33,12 +33,12 @@ const Layer& Display::GetLayer(std::size_t index) const {
return *layers.at(index);
}
-std::shared_ptr<Kernel::KReadableEvent> Display::GetVSyncEvent() const {
- return vsync_event->GetReadableEvent();
+Kernel::KReadableEvent& Display::GetVSyncEvent() {
+ return vsync_event.GetReadableEvent();
}
void Display::SignalVSyncEvent() {
- vsync_event->GetWritableEvent()->Signal();
+ vsync_event.GetWritableEvent().Signal();
}
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..388ce6083 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 @@
#include <string>
#include <vector>
+#include "common/common_funcs.h"
#include "common/common_types.h"
namespace Kernel {
@@ -24,6 +25,9 @@ class Layer;
/// Represents a single display type
class Display {
+ YUZU_NON_COPYABLE(Display);
+ YUZU_NON_MOVEABLE(Display);
+
public:
/// Constructs a display with a given unique ID and name.
///
@@ -33,12 +37,6 @@ public:
Display(u64 id, std::string name, Core::System& system);
~Display();
- Display(const Display&) = delete;
- Display& operator=(const Display&) = delete;
-
- Display(Display&&) = default;
- Display& operator=(Display&&) = default;
-
/// Gets the unique ID assigned to this display.
u64 GetID() const {
return id;
@@ -61,7 +59,7 @@ public:
const Layer& GetLayer(std::size_t index) const;
/// Gets the readable vsync event.
- std::shared_ptr<Kernel::KReadableEvent> GetVSyncEvent() const;
+ Kernel::KReadableEvent& GetVSyncEvent();
/// Signals the internal vsync event.
void SignalVSyncEvent();
@@ -102,7 +100,7 @@ private:
std::string name;
std::vector<std::shared_ptr<Layer>> layers;
- std::shared_ptr<Kernel::KEvent> vsync_event;
+ Kernel::KEvent vsync_event;
};
} // namespace Service::VI
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp
index 7ae07d072..32e47a43e 100644
--- a/src/core/hle/service/vi/vi.cpp
+++ b/src/core/hle/service/vi/vi.cpp
@@ -669,12 +669,10 @@ private:
LOG_WARNING(Service_VI, "(STUBBED) called id={}, unknown={:08X}", id, unknown);
- const auto& buffer_queue = *nv_flinger.FindBufferQueue(id);
-
// 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(nv_flinger.FindBufferQueue(id)->GetBufferWaitEvent());
}
NVFlinger::NVFlinger& nv_flinger;