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.cpp129
-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/apm/controller.cpp10
-rw-r--r--src/core/hle/service/apm/controller.h2
-rw-r--r--src/core/hle/service/audio/audout_u.cpp16
-rw-r--r--src/core/hle/service/audio/audren_u.cpp61
-rw-r--r--src/core/hle/service/audio/audren_u.h2
-rw-r--r--src/core/hle/service/audio/hwopus.cpp8
-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/backend/boxcat.cpp13
-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/controller_base.cpp2
-rw-r--r--src/core/hle/service/hid/controllers/controller_base.h2
-rw-r--r--src/core/hle/service/hid/controllers/gesture.cpp352
-rw-r--r--src/core/hle/service/hid/controllers/gesture.h77
-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.cpp16
-rw-r--r--src/core/hle/service/mii/manager.h2
-rw-r--r--src/core/hle/service/mii/mii.cpp4
-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.cpp18
-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/nvdevice.h2
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h12
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp8
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h12
-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/nvdrv/syncpoint_manager.cpp2
-rw-r--r--src/core/hle/service/nvdrv/syncpoint_manager.h2
-rw-r--r--src/core/hle/service/nvflinger/buffer_queue.cpp25
-rw-r--r--src/core/hle/service/nvflinger/buffer_queue.h11
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.cpp6
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.h8
-rw-r--r--src/core/hle/service/pctl/module.cpp2
-rw-r--r--src/core/hle/service/pctl/pctl.cpp4
-rw-r--r--src/core/hle/service/pctl/pctl.h2
-rw-r--r--src/core/hle/service/pm/pm.cpp27
-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.cpp68
-rw-r--r--src/core/hle/service/service.h49
-rw-r--r--src/core/hle/service/set/set_sys.cpp2
-rw-r--r--src/core/hle/service/sm/controller.cpp22
-rw-r--r--src/core/hle/service/sm/sm.cpp164
-rw-r--r--src/core/hle/service/sm/sm.h35
-rw-r--r--src/core/hle/service/ssl/ssl.cpp42
-rw-r--r--src/core/hle/service/time/ephemeral_network_system_clock_core.h4
-rw-r--r--src/core/hle/service/time/local_system_clock_context_writer.h4
-rw-r--r--src/core/hle/service/time/network_system_clock_context_writer.h4
-rw-r--r--src/core/hle/service/time/standard_local_system_clock_core.h4
-rw-r--r--src/core/hle/service/time/standard_network_system_clock_core.h10
-rw-r--r--src/core/hle/service/time/standard_user_system_clock_core.cpp29
-rw-r--r--src/core/hle/service/time/standard_user_system_clock_core.h11
-rw-r--r--src/core/hle/service/time/system_clock_core.cpp4
-rw-r--r--src/core/hle/service/time/system_clock_core.h2
-rw-r--r--src/core/hle/service/time/time.cpp5
-rw-r--r--src/core/hle/service/time/time_manager.cpp2
-rw-r--r--src/core/hle/service/time/time_manager.h2
-rw-r--r--src/core/hle/service/time/time_sharedmemory.cpp17
-rw-r--r--src/core/hle/service/time/time_sharedmemory.h6
-rw-r--r--src/core/hle/service/time/time_zone_content_manager.cpp4
-rw-r--r--src/core/hle/service/time/time_zone_content_manager.h2
-rw-r--r--src/core/hle/service/vi/display/vi_display.cpp14
-rw-r--r--src/core/hle/service/vi/display/vi_display.h22
-rw-r--r--src/core/hle/service/vi/layer/vi_layer.cpp2
-rw-r--r--src/core/hle/service/vi/layer/vi_layer.h4
-rw-r--r--src/core/hle/service/vi/vi.cpp28
93 files changed, 1101 insertions, 728 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..234173297 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_,
@@ -829,7 +833,7 @@ IStorageImpl::~IStorageImpl() = default;
class StorageDataImpl final : public IStorageImpl {
public:
- explicit StorageDataImpl(std::vector<u8>&& buffer) : buffer{std::move(buffer)} {}
+ explicit StorageDataImpl(std::vector<u8>&& buffer_) : buffer{std::move(buffer_)} {}
std::vector<u8>& GetData() override {
return buffer;
@@ -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;
@@ -1510,9 +1513,9 @@ void IApplicationFunctions::GetDisplayVersion(Kernel::HLERequestContext& ctx) {
const FileSys::PatchManager pm{title_id, system.GetFileSystemController(),
system.GetContentProvider()};
- auto res = pm.GetControlMetadata();
- if (res.first != nullptr) {
- return res;
+ auto metadata = pm.GetControlMetadata();
+ if (metadata.first != nullptr) {
+ return metadata;
}
const FileSys::PatchManager pm_update{FileSys::GetUpdateTitleID(title_id),
@@ -1547,9 +1550,9 @@ void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) {
const FileSys::PatchManager pm{title_id, system.GetFileSystemController(),
system.GetContentProvider()};
- auto res = pm.GetControlMetadata();
- if (res.first != nullptr) {
- return res;
+ auto metadata = pm.GetControlMetadata();
+ if (metadata.first != nullptr) {
+ return metadata;
}
const FileSys::PatchManager pm_update{FileSys::GetUpdateTitleID(title_id),
@@ -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/apm/controller.cpp b/src/core/hle/service/apm/controller.cpp
index 00c174bb0..8bfa7c0e4 100644
--- a/src/core/hle/service/apm/controller.cpp
+++ b/src/core/hle/service/apm/controller.cpp
@@ -15,11 +15,11 @@ namespace Service::APM {
constexpr auto DEFAULT_PERFORMANCE_CONFIGURATION = PerformanceConfiguration::Config7;
-Controller::Controller(Core::Timing::CoreTiming& core_timing)
- : core_timing{core_timing}, configs{
- {PerformanceMode::Handheld, DEFAULT_PERFORMANCE_CONFIGURATION},
- {PerformanceMode::Docked, DEFAULT_PERFORMANCE_CONFIGURATION},
- } {}
+Controller::Controller(Core::Timing::CoreTiming& core_timing_)
+ : core_timing{core_timing_}, configs{
+ {PerformanceMode::Handheld, DEFAULT_PERFORMANCE_CONFIGURATION},
+ {PerformanceMode::Docked, DEFAULT_PERFORMANCE_CONFIGURATION},
+ } {}
Controller::~Controller() = default;
diff --git a/src/core/hle/service/apm/controller.h b/src/core/hle/service/apm/controller.h
index af0c4cd34..8d48e0104 100644
--- a/src/core/hle/service/apm/controller.h
+++ b/src/core/hle/service/apm/controller.h
@@ -50,7 +50,7 @@ enum class PerformanceMode : u8 {
// system during times of high load -- this simply maps to different PerformanceConfigs to use.
class Controller {
public:
- explicit Controller(Core::Timing::CoreTiming& core_timing);
+ explicit Controller(Core::Timing::CoreTiming& core_timing_);
~Controller();
void SetPerformanceConfiguration(PerformanceMode mode, PerformanceConfiguration config);
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..ae4284adf 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,15 +162,16 @@ 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;
};
class IAudioDevice final : public ServiceFramework<IAudioDevice> {
public:
- explicit IAudioDevice(Core::System& system_, u32_le revision_num)
- : ServiceFramework{system_, "IAudioDevice"}, revision{revision_num} {
+ explicit IAudioDevice(Core::System& system_, Kernel::KEvent& buffer_event_, u32_le revision_)
+ : ServiceFramework{system_, "IAudioDevice"}, buffer_event{buffer_event_}, revision{
+ revision_} {
static const FunctionInfo functions[] = {
{0, &IAudioDevice::ListAudioDeviceName, "ListAudioDeviceName"},
{1, &IAudioDevice::SetAudioDeviceOutputVolume, "SetAudioDeviceOutputVolume"},
@@ -187,21 +188,6 @@ public:
{13, nullptr, "GetAudioSystemMasterVolumeSetting"},
};
RegisterHandlers(functions);
-
- auto& kernel = system.Kernel();
- buffer_event = Kernel::KEvent::Create(kernel, "IAudioOutBufferReleasedEvent");
- buffer_event->Initialize();
-
- // Should be similar to audio_output_device_switch_event
- audio_input_device_switch_event =
- Kernel::KEvent::Create(kernel, "IAudioDevice:AudioInputDeviceSwitchedEvent");
- audio_input_device_switch_event->Initialize();
-
- // Should only be signalled when an audio output device has been changed, example: speaker
- // to headset
- audio_output_device_switch_event =
- Kernel::KEvent::Create(kernel, "IAudioDevice:AudioOutputDeviceSwitchedEvent");
- audio_output_device_switch_event->Initialize();
}
private:
@@ -290,11 +276,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 +297,7 @@ private:
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(audio_input_device_switch_event->GetReadableEvent());
+ rb.PushCopyObjects(buffer_event.GetReadableEvent());
}
void QueryAudioDeviceOutputEvent(Kernel::HLERequestContext& ctx) {
@@ -319,17 +305,16 @@ private:
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(audio_output_device_switch_event->GetReadableEvent());
+ rb.PushCopyObjects(buffer_event.GetReadableEvent());
}
+ Kernel::KEvent& buffer_event;
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;
+};
-}; // namespace Audio
+AudRenU::AudRenU(Core::System& system_)
+ : ServiceFramework{system_, "audren:u"}, buffer_event{system.Kernel()} {
-AudRenU::AudRenU(Core::System& system_) : ServiceFramework{system_, "audren:u"} {
// clang-format off
static const FunctionInfo functions[] = {
{0, &AudRenU::OpenAudioRenderer, "OpenAudioRenderer"},
@@ -341,6 +326,9 @@ AudRenU::AudRenU(Core::System& system_) : ServiceFramework{system_, "audren:u"}
// clang-format on
RegisterHandlers(functions);
+
+ Kernel::KAutoObject::Create(std::addressof(buffer_event));
+ buffer_event.Initialize("IAudioOutBufferReleasedEvent");
}
AudRenU::~AudRenU() = default;
@@ -374,7 +362,7 @@ void AudRenU::GetAudioRendererWorkBufferSize(Kernel::HLERequestContext& ctx) {
static constexpr u64 max_perf_detail_entries = 100;
// Size of the data structure representing the bulk of the voice-related state.
- static constexpr u64 voice_state_size = 0x100;
+ static constexpr u64 voice_state_size_bytes = 0x100;
// Size of the upsampler manager data structure
constexpr u64 upsampler_manager_size = 0x48;
@@ -461,7 +449,8 @@ void AudRenU::GetAudioRendererWorkBufferSize(Kernel::HLERequestContext& ctx) {
size += Common::AlignUp(voice_info_size * params.voice_count, info_field_alignment_size);
size +=
Common::AlignUp(voice_resource_size * params.voice_count, info_field_alignment_size);
- size += Common::AlignUp(voice_state_size * params.voice_count, info_field_alignment_size);
+ size +=
+ Common::AlignUp(voice_state_size_bytes * params.voice_count, info_field_alignment_size);
return size;
};
@@ -663,7 +652,7 @@ void AudRenU::GetAudioDeviceService(Kernel::HLERequestContext& ctx) {
// always assumes the initial release revision (REV1).
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushIpcInterface<IAudioDevice>(system, Common::MakeMagic('R', 'E', 'V', '1'));
+ rb.PushIpcInterface<IAudioDevice>(system, buffer_event, Common::MakeMagic('R', 'E', 'V', '1'));
}
void AudRenU::OpenAudioRendererForManualExecution(Kernel::HLERequestContext& ctx) {
@@ -685,7 +674,7 @@ void AudRenU::GetAudioDeviceServiceWithRevisionInfo(Kernel::HLERequestContext& c
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushIpcInterface<IAudioDevice>(system, revision);
+ rb.PushIpcInterface<IAudioDevice>(system, buffer_event, revision);
}
void AudRenU::OpenAudioRendererImpl(Kernel::HLERequestContext& ctx) {
diff --git a/src/core/hle/service/audio/audren_u.h b/src/core/hle/service/audio/audren_u.h
index 37e8b4716..0ee6f9542 100644
--- a/src/core/hle/service/audio/audren_u.h
+++ b/src/core/hle/service/audio/audren_u.h
@@ -4,6 +4,7 @@
#pragma once
+#include "core/hle/kernel/k_event.h"
#include "core/hle/service/service.h"
namespace Core {
@@ -31,6 +32,7 @@ private:
void OpenAudioRendererImpl(Kernel::HLERequestContext& ctx);
std::size_t audren_instance_count = 0;
+ Kernel::KEvent buffer_event;
};
// Describes a particular audio feature that may be supported in a particular revision.
diff --git a/src/core/hle/service/audio/hwopus.cpp b/src/core/hle/service/audio/hwopus.cpp
index 19c578b3a..ee5ec8cd6 100644
--- a/src/core/hle/service/audio/hwopus.cpp
+++ b/src/core/hle/service/audio/hwopus.cpp
@@ -50,8 +50,8 @@ public:
Enabled,
};
- explicit OpusDecoderState(OpusDecoderPtr decoder, u32 sample_rate, u32 channel_count)
- : decoder{std::move(decoder)}, sample_rate{sample_rate}, channel_count{channel_count} {}
+ explicit OpusDecoderState(OpusDecoderPtr decoder_, u32 sample_rate_, u32 channel_count_)
+ : decoder{std::move(decoder_)}, sample_rate{sample_rate_}, channel_count{channel_count_} {}
// Decodes interleaved Opus packets. Optionally allows reporting time taken to
// perform the decoding, as well as any relevant extra behavior.
@@ -160,9 +160,9 @@ private:
class IHardwareOpusDecoderManager final : public ServiceFramework<IHardwareOpusDecoderManager> {
public:
- explicit IHardwareOpusDecoderManager(Core::System& system_, OpusDecoderState decoder_state)
+ explicit IHardwareOpusDecoderManager(Core::System& system_, OpusDecoderState decoder_state_)
: ServiceFramework{system_, "IHardwareOpusDecoderManager"}, decoder_state{
- std::move(decoder_state)} {
+ std::move(decoder_state_)} {
// clang-format off
static const FunctionInfo functions[] = {
{0, &IHardwareOpusDecoderManager::DecodeInterleavedOld, "DecodeInterleavedOld"},
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/backend/boxcat.cpp b/src/core/hle/service/bcat/backend/boxcat.cpp
index cee1774d1..d6d2f52e5 100644
--- a/src/core/hle/service/bcat/backend/boxcat.cpp
+++ b/src/core/hle/service/bcat/backend/boxcat.cpp
@@ -3,9 +3,18 @@
// Refer to the license.txt file included.
#include <fmt/ostream.h>
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wshadow"
+#endif
#include <httplib.h>
#include <mbedtls/sha256.h>
#include <nlohmann/json.hpp>
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+
#include "common/hex_util.h"
#include "common/logging/backend.h"
#include "common/logging/log.h"
@@ -178,8 +187,8 @@ bool VfsRawCopyDProgress(FileSys::VirtualDir src, FileSys::VirtualDir dest,
class Boxcat::Client {
public:
- Client(std::string path, u64 title_id, u64 build_id)
- : path(std::move(path)), title_id(title_id), build_id(build_id) {}
+ Client(std::string path_, u64 title_id_, u64 build_id_)
+ : path(std::move(path_)), title_id(title_id_), build_id(build_id_) {}
DownloadResult DownloadDataZip() {
return DownloadInternal(fmt::format(BOXCAT_PATHNAME_DATA, title_id), TIMEOUT_SECONDS,
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/controller_base.cpp b/src/core/hle/service/hid/controllers/controller_base.cpp
index 8091db9d7..9d1e6db6a 100644
--- a/src/core/hle/service/hid/controllers/controller_base.cpp
+++ b/src/core/hle/service/hid/controllers/controller_base.cpp
@@ -6,7 +6,7 @@
namespace Service::HID {
-ControllerBase::ControllerBase(Core::System& system) : system(system) {}
+ControllerBase::ControllerBase(Core::System& system_) : system(system_) {}
ControllerBase::~ControllerBase() = default;
void ControllerBase::ActivateController() {
diff --git a/src/core/hle/service/hid/controllers/controller_base.h b/src/core/hle/service/hid/controllers/controller_base.h
index f47a9e61c..1556fb08e 100644
--- a/src/core/hle/service/hid/controllers/controller_base.h
+++ b/src/core/hle/service/hid/controllers/controller_base.h
@@ -18,7 +18,7 @@ class System;
namespace Service::HID {
class ControllerBase {
public:
- explicit ControllerBase(Core::System& system);
+ explicit ControllerBase(Core::System& system_);
virtual ~ControllerBase();
// Called when the controller is initialized
diff --git a/src/core/hle/service/hid/controllers/gesture.cpp b/src/core/hle/service/hid/controllers/gesture.cpp
index bb77d8959..d311f754b 100644
--- a/src/core/hle/service/hid/controllers/gesture.cpp
+++ b/src/core/hle/service/hid/controllers/gesture.cpp
@@ -1,10 +1,9 @@
-// Copyright 2018 yuzu emulator team
+// Copyright 2021 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
-#include <cstring>
-#include "common/common_types.h"
#include "common/logging/log.h"
+#include "common/math_util.h"
#include "common/settings.h"
#include "core/core_timing.h"
#include "core/frontend/emu_window.h"
@@ -12,10 +11,19 @@
namespace Service::HID {
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3BA00;
-constexpr f32 angle_threshold = 0.08f;
-constexpr f32 pinch_threshold = 100.0f;
-Controller_Gesture::Controller_Gesture(Core::System& system_) : ControllerBase{system_} {}
+// HW is around 700, value is set to 400 to make it easier to trigger with mouse
+constexpr f32 swipe_threshold = 400.0f; // Threshold in pixels/s
+constexpr f32 angle_threshold = 0.015f; // Threshold in radians
+constexpr f32 pinch_threshold = 0.5f; // Threshold in pixels
+constexpr f32 press_delay = 0.5f; // Time in seconds
+constexpr f32 double_tap_delay = 0.35f; // Time in seconds
+
+constexpr f32 Square(s32 num) {
+ return static_cast<f32>(num * num);
+}
+
+Controller_Gesture::Controller_Gesture(Core::System& system_) : ControllerBase(system_) {}
Controller_Gesture::~Controller_Gesture() = default;
void Controller_Gesture::OnInit() {
@@ -24,6 +32,8 @@ void Controller_Gesture::OnInit() {
keyboard_finger_id[id] = MAX_POINTS;
udp_finger_id[id] = MAX_POINTS;
}
+ shared_memory.header.entry_count = 0;
+ force_update = true;
}
void Controller_Gesture::OnRelease() {}
@@ -38,17 +48,23 @@ void Controller_Gesture::OnUpdate(const Core::Timing::CoreTiming& core_timing, u
shared_memory.header.last_entry_index = 0;
return;
}
- shared_memory.header.entry_count = 16;
- const auto& last_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index];
- shared_memory.header.last_entry_index = (shared_memory.header.last_entry_index + 1) % 17;
- auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index];
+ ReadTouchInput();
- cur_entry.sampling_number = last_entry.sampling_number + 1;
- cur_entry.sampling_number2 = cur_entry.sampling_number;
+ GestureProperties gesture = GetGestureProperties();
+ f32 time_difference = static_cast<f32>(shared_memory.header.timestamp - last_update_timestamp) /
+ (1000 * 1000 * 1000);
- // TODO(german77): Implement all gesture types
+ // Only update if necesary
+ if (!ShouldUpdateGesture(gesture, time_difference)) {
+ return;
+ }
+ last_update_timestamp = shared_memory.header.timestamp;
+ UpdateGestureSharedMemory(data, size, gesture, time_difference);
+}
+
+void Controller_Gesture::ReadTouchInput() {
const Input::TouchStatus& mouse_status = touch_mouse_device->GetStatus();
const Input::TouchStatus& udp_status = touch_udp_device->GetStatus();
for (std::size_t id = 0; id < mouse_status.size(); ++id) {
@@ -63,50 +79,71 @@ void Controller_Gesture::OnUpdate(const Core::Timing::CoreTiming& core_timing, u
UpdateTouchInputEvent(keyboard_status[id], keyboard_finger_id[id]);
}
}
+}
- TouchType type = TouchType::Idle;
- Attribute attributes{};
- GestureProperties gesture = GetGestureProperties();
- if (last_gesture.active_points != gesture.active_points) {
- ++last_gesture.detection_count;
+bool Controller_Gesture::ShouldUpdateGesture(const GestureProperties& gesture,
+ f32 time_difference) {
+ const auto& last_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index];
+ if (force_update) {
+ force_update = false;
+ return true;
}
- if (gesture.active_points > 0) {
- if (last_gesture.active_points == 0) {
- attributes.is_new_touch.Assign(true);
- last_gesture.average_distance = gesture.average_distance;
- last_gesture.angle = gesture.angle;
- }
- type = TouchType::Touch;
- if (gesture.mid_point.x != last_entry.x || gesture.mid_point.y != last_entry.y) {
- type = TouchType::Pan;
- }
- if (std::abs(gesture.average_distance - last_gesture.average_distance) > pinch_threshold) {
- type = TouchType::Pinch;
- }
- if (std::abs(gesture.angle - last_gesture.angle) > angle_threshold) {
- type = TouchType::Rotate;
+ // Update if coordinates change
+ for (size_t id = 0; id < MAX_POINTS; id++) {
+ if (gesture.points[id].x != last_gesture.points[id].x ||
+ gesture.points[id].y != last_gesture.points[id].y) {
+ return true;
}
+ }
+
+ // Update on press and hold event after 0.5 seconds
+ if (last_entry.type == TouchType::Touch && last_entry.point_count == 1 &&
+ time_difference > press_delay) {
+ return enable_press_and_tap;
+ }
+
+ return false;
+}
+
+void Controller_Gesture::UpdateGestureSharedMemory(u8* data, std::size_t size,
+ GestureProperties& gesture,
+ f32 time_difference) {
+ TouchType type = TouchType::Idle;
+ Attribute attributes{};
+
+ const auto& last_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index];
+ shared_memory.header.last_entry_index = (shared_memory.header.last_entry_index + 1) % 17;
+ auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index];
- cur_entry.delta_x = gesture.mid_point.x - last_entry.x;
- cur_entry.delta_y = gesture.mid_point.y - last_entry.y;
- // TODO: Find how velocities are calculated
- cur_entry.vel_x = static_cast<float>(cur_entry.delta_x) * 150.1f;
- cur_entry.vel_y = static_cast<float>(cur_entry.delta_y) * 150.1f;
+ if (shared_memory.header.entry_count < 16) {
+ shared_memory.header.entry_count++;
+ }
- // Slowdown the rate of change for less flapping
- last_gesture.average_distance =
- (last_gesture.average_distance * 0.9f) + (gesture.average_distance * 0.1f);
- last_gesture.angle = (last_gesture.angle * 0.9f) + (gesture.angle * 0.1f);
+ cur_entry.sampling_number = last_entry.sampling_number + 1;
+ cur_entry.sampling_number2 = cur_entry.sampling_number;
+ // Reset values to default
+ cur_entry.delta_x = 0;
+ cur_entry.delta_y = 0;
+ cur_entry.vel_x = 0;
+ cur_entry.vel_y = 0;
+ cur_entry.direction = Direction::None;
+ cur_entry.rotation_angle = 0;
+ cur_entry.scale = 0;
+
+ if (gesture.active_points > 0) {
+ if (last_gesture.active_points == 0) {
+ NewGesture(gesture, type, attributes);
+ } else {
+ UpdateExistingGesture(gesture, type, time_difference);
+ }
} else {
- cur_entry.delta_x = 0;
- cur_entry.delta_y = 0;
- cur_entry.vel_x = 0;
- cur_entry.vel_y = 0;
+ EndGesture(gesture, last_gesture, type, attributes, time_difference);
}
- last_gesture.active_points = gesture.active_points;
- cur_entry.detection_count = last_gesture.detection_count;
+
+ // Apply attributes
+ cur_entry.detection_count = gesture.detection_count;
cur_entry.type = type;
cur_entry.attributes = attributes;
cur_entry.x = gesture.mid_point.x;
@@ -116,12 +153,195 @@ void Controller_Gesture::OnUpdate(const Core::Timing::CoreTiming& core_timing, u
cur_entry.points[id].x = gesture.points[id].x;
cur_entry.points[id].y = gesture.points[id].y;
}
- cur_entry.rotation_angle = 0;
- cur_entry.scale = 0;
+ last_gesture = gesture;
std::memcpy(data + SHARED_MEMORY_OFFSET, &shared_memory, sizeof(SharedMemory));
}
+void Controller_Gesture::NewGesture(GestureProperties& gesture, TouchType& type,
+ Attribute& attributes) {
+ const auto& last_entry =
+ shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17];
+ gesture.detection_count++;
+ type = TouchType::Touch;
+
+ // New touch after cancel is not considered new
+ if (last_entry.type != TouchType::Cancel) {
+ attributes.is_new_touch.Assign(1);
+ enable_press_and_tap = true;
+ }
+}
+
+void Controller_Gesture::UpdateExistingGesture(GestureProperties& gesture, TouchType& type,
+ f32 time_difference) {
+ const auto& last_entry =
+ shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17];
+
+ // Promote to pan type if touch moved
+ for (size_t id = 0; id < MAX_POINTS; id++) {
+ if (gesture.points[id].x != last_gesture.points[id].x ||
+ gesture.points[id].y != last_gesture.points[id].y) {
+ type = TouchType::Pan;
+ break;
+ }
+ }
+
+ // Number of fingers changed cancel the last event and clear data
+ if (gesture.active_points != last_gesture.active_points) {
+ type = TouchType::Cancel;
+ enable_press_and_tap = false;
+ gesture.active_points = 0;
+ gesture.mid_point = {};
+ for (size_t id = 0; id < MAX_POINTS; id++) {
+ gesture.points[id].x = 0;
+ gesture.points[id].y = 0;
+ }
+ return;
+ }
+
+ // Calculate extra parameters of panning
+ if (type == TouchType::Pan) {
+ UpdatePanEvent(gesture, last_gesture, type, time_difference);
+ return;
+ }
+
+ // Promote to press type
+ if (last_entry.type == TouchType::Touch) {
+ type = TouchType::Press;
+ }
+}
+
+void Controller_Gesture::EndGesture(GestureProperties& gesture,
+ GestureProperties& last_gesture_props, TouchType& type,
+ Attribute& attributes, f32 time_difference) {
+ const auto& last_entry =
+ shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17];
+ if (last_gesture_props.active_points != 0) {
+ switch (last_entry.type) {
+ case TouchType::Touch:
+ if (enable_press_and_tap) {
+ SetTapEvent(gesture, last_gesture_props, type, attributes);
+ return;
+ }
+ type = TouchType::Cancel;
+ force_update = true;
+ break;
+ case TouchType::Press:
+ case TouchType::Tap:
+ case TouchType::Swipe:
+ case TouchType::Pinch:
+ case TouchType::Rotate:
+ type = TouchType::Complete;
+ force_update = true;
+ break;
+ case TouchType::Pan:
+ EndPanEvent(gesture, last_gesture_props, type, time_difference);
+ break;
+ default:
+ break;
+ }
+ return;
+ }
+ if (last_entry.type == TouchType::Complete || last_entry.type == TouchType::Cancel) {
+ gesture.detection_count++;
+ }
+}
+
+void Controller_Gesture::SetTapEvent(GestureProperties& gesture,
+ GestureProperties& last_gesture_props, TouchType& type,
+ Attribute& attributes) {
+ type = TouchType::Tap;
+ gesture = last_gesture_props;
+ force_update = true;
+ f32 tap_time_difference =
+ static_cast<f32>(last_update_timestamp - last_tap_timestamp) / (1000 * 1000 * 1000);
+ last_tap_timestamp = last_update_timestamp;
+ if (tap_time_difference < double_tap_delay) {
+ attributes.is_double_tap.Assign(1);
+ }
+}
+
+void Controller_Gesture::UpdatePanEvent(GestureProperties& gesture,
+ GestureProperties& last_gesture_props, TouchType& type,
+ f32 time_difference) {
+ auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index];
+ const auto& last_entry =
+ shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17];
+ cur_entry.delta_x = gesture.mid_point.x - last_entry.x;
+ cur_entry.delta_y = gesture.mid_point.y - last_entry.y;
+
+ cur_entry.vel_x = static_cast<f32>(cur_entry.delta_x) / time_difference;
+ cur_entry.vel_y = static_cast<f32>(cur_entry.delta_y) / time_difference;
+ last_pan_time_difference = time_difference;
+
+ // Promote to pinch type
+ if (std::abs(gesture.average_distance - last_gesture_props.average_distance) >
+ pinch_threshold) {
+ type = TouchType::Pinch;
+ cur_entry.scale = gesture.average_distance / last_gesture_props.average_distance;
+ }
+
+ const f32 angle_between_two_lines = std::atan((gesture.angle - last_gesture_props.angle) /
+ (1 + (gesture.angle * last_gesture_props.angle)));
+ // Promote to rotate type
+ if (std::abs(angle_between_two_lines) > angle_threshold) {
+ type = TouchType::Rotate;
+ cur_entry.scale = 0;
+ cur_entry.rotation_angle = angle_between_two_lines * 180.0f / Common::PI;
+ }
+}
+
+void Controller_Gesture::EndPanEvent(GestureProperties& gesture,
+ GestureProperties& last_gesture_props, TouchType& type,
+ f32 time_difference) {
+ auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index];
+ const auto& last_entry =
+ shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17];
+ cur_entry.vel_x =
+ static_cast<f32>(last_entry.delta_x) / (last_pan_time_difference + time_difference);
+ cur_entry.vel_y =
+ static_cast<f32>(last_entry.delta_y) / (last_pan_time_difference + time_difference);
+ const f32 curr_vel =
+ std::sqrt((cur_entry.vel_x * cur_entry.vel_x) + (cur_entry.vel_y * cur_entry.vel_y));
+
+ // Set swipe event with parameters
+ if (curr_vel > swipe_threshold) {
+ SetSwipeEvent(gesture, last_gesture_props, type);
+ return;
+ }
+
+ // End panning without swipe
+ type = TouchType::Complete;
+ cur_entry.vel_x = 0;
+ cur_entry.vel_y = 0;
+ force_update = true;
+}
+
+void Controller_Gesture::SetSwipeEvent(GestureProperties& gesture,
+ GestureProperties& last_gesture_props, TouchType& type) {
+ auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index];
+ const auto& last_entry =
+ shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17];
+ type = TouchType::Swipe;
+ gesture = last_gesture_props;
+ force_update = true;
+ cur_entry.delta_x = last_entry.delta_x;
+ cur_entry.delta_y = last_entry.delta_y;
+ if (std::abs(cur_entry.delta_x) > std::abs(cur_entry.delta_y)) {
+ if (cur_entry.delta_x > 0) {
+ cur_entry.direction = Direction::Right;
+ return;
+ }
+ cur_entry.direction = Direction::Left;
+ return;
+ }
+ if (cur_entry.delta_y > 0) {
+ cur_entry.direction = Direction::Down;
+ return;
+ }
+ cur_entry.direction = Direction::Up;
+}
+
void Controller_Gesture::OnLoadInputDevices() {
touch_mouse_device = Input::CreateDevice<Input::TouchDevice>("engine:emu_window");
touch_udp_device = Input::CreateDevice<Input::TouchDevice>("engine:cemuhookudp");
@@ -183,23 +403,33 @@ Controller_Gesture::GestureProperties Controller_Gesture::GetGestureProperties()
for (size_t id = 0; id < gesture.active_points; ++id) {
gesture.points[id].x =
- static_cast<int>(active_fingers[id].x * Layout::ScreenUndocked::Width);
+ static_cast<s32>(active_fingers[id].x * Layout::ScreenUndocked::Width);
gesture.points[id].y =
- static_cast<int>(active_fingers[id].y * Layout::ScreenUndocked::Height);
- gesture.mid_point.x += static_cast<int>(gesture.points[id].x / gesture.active_points);
- gesture.mid_point.y += static_cast<int>(gesture.points[id].y / gesture.active_points);
+ static_cast<s32>(active_fingers[id].y * Layout::ScreenUndocked::Height);
+
+ // Hack: There is no touch in docked but games still allow it
+ if (Settings::values.use_docked_mode.GetValue()) {
+ gesture.points[id].x =
+ static_cast<s32>(active_fingers[id].x * Layout::ScreenDocked::Width);
+ gesture.points[id].y =
+ static_cast<s32>(active_fingers[id].y * Layout::ScreenDocked::Height);
+ }
+
+ gesture.mid_point.x += static_cast<s32>(gesture.points[id].x / gesture.active_points);
+ gesture.mid_point.y += static_cast<s32>(gesture.points[id].y / gesture.active_points);
}
for (size_t id = 0; id < gesture.active_points; ++id) {
- const double distance =
- std::pow(static_cast<float>(gesture.mid_point.x - gesture.points[id].x), 2) +
- std::pow(static_cast<float>(gesture.mid_point.y - gesture.points[id].y), 2);
- gesture.average_distance +=
- static_cast<float>(distance) / static_cast<float>(gesture.active_points);
+ const f32 distance = std::sqrt(Square(gesture.mid_point.x - gesture.points[id].x) +
+ Square(gesture.mid_point.y - gesture.points[id].y));
+ gesture.average_distance += distance / static_cast<f32>(gesture.active_points);
}
- gesture.angle = std::atan2(static_cast<float>(gesture.mid_point.y - gesture.points[0].y),
- static_cast<float>(gesture.mid_point.x - gesture.points[0].x));
+ gesture.angle = std::atan2(static_cast<f32>(gesture.mid_point.y - gesture.points[0].y),
+ static_cast<f32>(gesture.mid_point.x - gesture.points[0].x));
+
+ gesture.detection_count = last_gesture.detection_count;
+
return gesture;
}
diff --git a/src/core/hle/service/hid/controllers/gesture.h b/src/core/hle/service/hid/controllers/gesture.h
index 7c357b977..f46e29411 100644
--- a/src/core/hle/service/hid/controllers/gesture.h
+++ b/src/core/hle/service/hid/controllers/gesture.h
@@ -1,4 +1,4 @@
-// Copyright 2018 yuzu emulator team
+// Copyright 2021 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
@@ -7,7 +7,6 @@
#include <array>
#include "common/bit_field.h"
#include "common/common_types.h"
-#include "common/swap.h"
#include "core/frontend/input.h"
#include "core/hle/service/hid/controllers/controller_base.h"
@@ -35,10 +34,10 @@ private:
enum class TouchType : u32 {
Idle, // Nothing touching the screen
- Complete, // Unknown. End of touch?
- Cancel, // Never triggered
- Touch, // Pressing without movement
- Press, // Never triggered
+ Complete, // Set at the end of a touch event
+ Cancel, // Set when the number of fingers change
+ Touch, // A finger just touched the screen
+ Press, // Set if last type is touch and the finger hasn't moved
Tap, // Fast press then release
Pan, // All points moving together across the screen
Swipe, // Fast press movement and release of a single point
@@ -58,8 +57,8 @@ private:
union {
u32_le raw{};
- BitField<0, 1, u32> is_new_touch;
- BitField<1, 1, u32> is_double_tap;
+ BitField<4, 1, u32> is_new_touch;
+ BitField<8, 1, u32> is_double_tap;
};
};
static_assert(sizeof(Attribute) == 4, "Attribute is an invalid size");
@@ -73,10 +72,9 @@ private:
struct GestureState {
s64_le sampling_number;
s64_le sampling_number2;
-
s64_le detection_count;
TouchType type;
- Direction dir;
+ Direction direction;
s32_le x;
s32_le y;
s32_le delta_x;
@@ -84,8 +82,8 @@ private:
f32 vel_x;
f32 vel_y;
Attribute attributes;
- u32 scale;
- u32 rotation_angle;
+ f32 scale;
+ f32 rotation_angle;
s32_le point_count;
std::array<Points, 4> points;
};
@@ -109,17 +107,55 @@ private:
Points mid_point{};
s64_le detection_count{};
u64_le delta_time{};
- float average_distance{};
- float angle{};
+ f32 average_distance{};
+ f32 angle{};
};
- // Returns an unused finger id, if there is no fingers avaliable MAX_FINGERS will be returned
+ // Reads input from all available input engines
+ void ReadTouchInput();
+
+ // Returns true if gesture state needs to be updated
+ bool ShouldUpdateGesture(const GestureProperties& gesture, f32 time_difference);
+
+ // Updates the shared memory to the next state
+ void UpdateGestureSharedMemory(u8* data, std::size_t size, GestureProperties& gesture,
+ f32 time_difference);
+
+ // Initializes new gesture
+ void NewGesture(GestureProperties& gesture, TouchType& type, Attribute& attributes);
+
+ // Updates existing gesture state
+ void UpdateExistingGesture(GestureProperties& gesture, TouchType& type, f32 time_difference);
+
+ // Terminates exiting gesture
+ void EndGesture(GestureProperties& gesture, GestureProperties& last_gesture_props,
+ TouchType& type, Attribute& attributes, f32 time_difference);
+
+ // Set current event to a tap event
+ void SetTapEvent(GestureProperties& gesture, GestureProperties& last_gesture_props,
+ TouchType& type, Attribute& attributes);
+
+ // Calculates and set the extra parameters related to a pan event
+ void UpdatePanEvent(GestureProperties& gesture, GestureProperties& last_gesture_props,
+ TouchType& type, f32 time_difference);
+
+ // Terminates the pan event
+ void EndPanEvent(GestureProperties& gesture, GestureProperties& last_gesture_props,
+ TouchType& type, f32 time_difference);
+
+ // Set current event to a swipe event
+ void SetSwipeEvent(GestureProperties& gesture, GestureProperties& last_gesture_props,
+ TouchType& type);
+
+ // Returns an unused finger id, if there is no fingers available std::nullopt is returned.
std::optional<size_t> GetUnusedFingerID() const;
- /** If the touch is new it tries to assing a new finger id, if there is no fingers avaliable no
+ /**
+ * If the touch is new it tries to assign a new finger id, if there is no fingers available no
* changes will be made. Updates the coordinates if the finger id it's already set. If the touch
* ends delays the output by one frame to set the end_touch flag before finally freeing the
- * finger id */
+ * finger id
+ */
size_t UpdateTouchInputEvent(const std::tuple<float, float, bool>& touch_input,
size_t finger_id);
@@ -134,6 +170,11 @@ private:
std::array<size_t, MAX_FINGERS> keyboard_finger_id;
std::array<size_t, MAX_FINGERS> udp_finger_id;
std::array<Finger, MAX_POINTS> fingers;
- GestureProperties last_gesture;
+ GestureProperties last_gesture{};
+ s64_le last_update_timestamp{};
+ s64_le last_tap_timestamp{};
+ f32 last_pan_time_difference{};
+ bool force_update{false};
+ bool enable_press_and_tap{false};
};
} // namespace Service::HID
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 c8bc60ad1..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};
@@ -387,11 +387,9 @@ public:
const VAddr bss_end_addr{
Common::AlignUp(bss_start + nro_header.bss_size, Kernel::PageSize)};
- auto CopyCode{[&](VAddr src_addr, VAddr dst_addr, u64 size) {
- std::vector<u8> source_data(size);
- system.Memory().ReadBlock(src_addr, source_data.data(), source_data.size());
- system.Memory().WriteBlock(dst_addr, source_data.data(), source_data.size());
- }};
+ const auto CopyCode = [this, process](VAddr src_addr, VAddr dst_addr, u64 size) {
+ system.Memory().CopyBlock(*process, dst_addr, src_addr, size);
+ };
CopyCode(nro_addr + nro_header.segment_headers[TEXT_INDEX].memory_offset, text_start,
nro_header.segment_headers[TEXT_INDEX].memory_size);
CopyCode(nro_addr + nro_header.segment_headers[RO_INDEX].memory_offset, ro_start,
diff --git a/src/core/hle/service/mii/manager.h b/src/core/hle/service/mii/manager.h
index 2106a528a..ec7efa5f7 100644
--- a/src/core/hle/service/mii/manager.h
+++ b/src/core/hle/service/mii/manager.h
@@ -89,7 +89,7 @@ static_assert(std::has_unique_object_representations_v<MiiInfo>,
#pragma pack(push, 4)
struct MiiInfoElement {
- MiiInfoElement(const MiiInfo& info, Source source) : info{info}, source{source} {}
+ MiiInfoElement(const MiiInfo& info_, Source source_) : info{info_}, source{source_} {}
MiiInfo info{};
Source source{};
diff --git a/src/core/hle/service/mii/mii.cpp b/src/core/hle/service/mii/mii.cpp
index 26be9e45b..81f150a88 100644
--- a/src/core/hle/service/mii/mii.cpp
+++ b/src/core/hle/service/mii/mii.cpp
@@ -253,8 +253,8 @@ private:
class MiiDBModule final : public ServiceFramework<MiiDBModule> {
public:
- explicit MiiDBModule(Core::System& system_, const char* name)
- : ServiceFramework{system_, name} {
+ explicit MiiDBModule(Core::System& system_, const char* name_)
+ : ServiceFramework{system_, name_} {
// clang-format off
static const FunctionInfo functions[] = {
{0, &MiiDBModule::GetDatabaseService, "GetDatabaseService"},
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..76e3832df 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> {
@@ -368,7 +368,7 @@ private:
},
};
- IPC::ResponseBuilder rb{ctx, 2 + sizeof(IpConfigInfo) / sizeof(u32)};
+ IPC::ResponseBuilder rb{ctx, 2 + (sizeof(IpConfigInfo) + 3) / sizeof(u32)};
rb.Push(RESULT_SUCCESS);
rb.PushRaw<IpConfigInfo>(ip_config_info);
}
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/nvdevice.h b/src/core/hle/service/nvdrv/devices/nvdevice.h
index b37f023df..5b73a5a34 100644
--- a/src/core/hle/service/nvdrv/devices/nvdevice.h
+++ b/src/core/hle/service/nvdrv/devices/nvdevice.h
@@ -21,7 +21,7 @@ namespace Service::Nvidia::Devices {
/// implement the ioctl interface.
class nvdevice {
public:
- explicit nvdevice(Core::System& system) : system{system} {}
+ explicit nvdevice(Core::System& system_) : system{system_} {}
virtual ~nvdevice() = default;
/**
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h
index 229bf6350..24e3151cb 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h
@@ -48,13 +48,13 @@ private:
public:
constexpr BufferMap() = default;
- constexpr BufferMap(GPUVAddr start_addr, std::size_t size)
- : start_addr{start_addr}, end_addr{start_addr + size} {}
+ constexpr BufferMap(GPUVAddr start_addr_, std::size_t size_)
+ : start_addr{start_addr_}, end_addr{start_addr_ + size_} {}
- constexpr BufferMap(GPUVAddr start_addr, std::size_t size, VAddr cpu_addr,
- bool is_allocated)
- : start_addr{start_addr}, end_addr{start_addr + size}, cpu_addr{cpu_addr},
- is_allocated{is_allocated} {}
+ constexpr BufferMap(GPUVAddr start_addr_, std::size_t size_, VAddr cpu_addr_,
+ bool is_allocated_)
+ : start_addr{start_addr_}, end_addr{start_addr_ + size_}, cpu_addr{cpu_addr_},
+ is_allocated{is_allocated_} {}
constexpr VAddr StartAddr() const {
return start_addr;
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/devices/nvhost_nvdec_common.h b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h
index 14d0d210a..da10f5f41 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h
@@ -27,13 +27,13 @@ protected:
public:
constexpr BufferMap() = default;
- constexpr BufferMap(GPUVAddr start_addr, std::size_t size)
- : start_addr{start_addr}, end_addr{start_addr + size} {}
+ constexpr BufferMap(GPUVAddr start_addr_, std::size_t size_)
+ : start_addr{start_addr_}, end_addr{start_addr_ + size_} {}
- constexpr BufferMap(GPUVAddr start_addr, std::size_t size, VAddr cpu_addr,
- bool is_allocated)
- : start_addr{start_addr}, end_addr{start_addr + size}, cpu_addr{cpu_addr},
- is_allocated{is_allocated} {}
+ constexpr BufferMap(GPUVAddr start_addr_, std::size_t size_, VAddr cpu_addr_,
+ bool is_allocated_)
+ : start_addr{start_addr_}, end_addr{start_addr_ + size_}, cpu_addr{cpu_addr_},
+ is_allocated{is_allocated_} {}
constexpr VAddr StartAddr() const {
return start_addr;
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/nvdrv/syncpoint_manager.cpp b/src/core/hle/service/nvdrv/syncpoint_manager.cpp
index 0151a03b7..3b6f55526 100644
--- a/src/core/hle/service/nvdrv/syncpoint_manager.cpp
+++ b/src/core/hle/service/nvdrv/syncpoint_manager.cpp
@@ -8,7 +8,7 @@
namespace Service::Nvidia {
-SyncpointManager::SyncpointManager(Tegra::GPU& gpu) : gpu{gpu} {}
+SyncpointManager::SyncpointManager(Tegra::GPU& gpu_) : gpu{gpu_} {}
SyncpointManager::~SyncpointManager() = default;
diff --git a/src/core/hle/service/nvdrv/syncpoint_manager.h b/src/core/hle/service/nvdrv/syncpoint_manager.h
index d395c5d0b..99f286474 100644
--- a/src/core/hle/service/nvdrv/syncpoint_manager.h
+++ b/src/core/hle/service/nvdrv/syncpoint_manager.h
@@ -18,7 +18,7 @@ namespace Service::Nvidia {
class SyncpointManager final {
public:
- explicit SyncpointManager(Tegra::GPU& gpu);
+ explicit SyncpointManager(Tegra::GPU& gpu_);
~SyncpointManager();
/**
diff --git a/src/core/hle/service/nvflinger/buffer_queue.cpp b/src/core/hle/service/nvflinger/buffer_queue.cpp
index 7842a82ed..59ddf6298 100644
--- a/src/core/hle/service/nvflinger/buffer_queue.cpp
+++ b/src/core/hle/service/nvflinger/buffer_queue.cpp
@@ -7,17 +7,16 @@
#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"
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();
+BufferQueue::BufferQueue(Kernel::KernelCore& kernel, u32 id_, u64 layer_id_)
+ : 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..61e337ac5 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 {
@@ -53,7 +54,7 @@ public:
NativeWindowFormat = 2,
};
- explicit BufferQueue(Kernel::KernelCore& kernel, u32 id, u64 layer_id);
+ explicit BufferQueue(Kernel::KernelCore& kernel, u32 id_, u64 layer_id_);
~BufferQueue();
enum class BufferTransformFlags : u32 {
@@ -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 810312dc4..d1dbc659b 100644
--- a/src/core/hle/service/nvflinger/nvflinger.cpp
+++ b/src/core/hle/service/nvflinger/nvflinger.cpp
@@ -61,7 +61,7 @@ void NVFlinger::SplitVSync() {
}
}
-NVFlinger::NVFlinger(Core::System& system) : system(system) {
+NVFlinger::NVFlinger(Core::System& system_) : system(system_) {
displays.emplace_back(0, "Default", system);
displays.emplace_back(1, "External", system);
displays.emplace_back(2, "Edid", system);
@@ -169,7 +169,7 @@ std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) {
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);
@@ -177,7 +177,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 ebc82c688..d80fd07ef 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;
@@ -45,7 +45,7 @@ class BufferQueue;
class NVFlinger final {
public:
- explicit NVFlinger(Core::System& system);
+ explicit NVFlinger(Core::System& system_);
~NVFlinger();
/// Sets the NVDrv module instance to use to send buffers to the GPU.
@@ -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);
@@ -114,7 +114,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/pctl/pctl.cpp b/src/core/hle/service/pctl/pctl.cpp
index e4d155c86..908e0a1e3 100644
--- a/src/core/hle/service/pctl/pctl.cpp
+++ b/src/core/hle/service/pctl/pctl.cpp
@@ -7,8 +7,8 @@
namespace Service::PCTL {
PCTL::PCTL(Core::System& system_, std::shared_ptr<Module> module_, const char* name,
- Capability capability)
- : Interface{system_, std::move(module_), name, capability} {
+ Capability capability_)
+ : Interface{system_, std::move(module_), name, capability_} {
static const FunctionInfo functions[] = {
{0, &PCTL::CreateService, "CreateService"},
{1, &PCTL::CreateServiceWithoutInitialize, "CreateServiceWithoutInitialize"},
diff --git a/src/core/hle/service/pctl/pctl.h b/src/core/hle/service/pctl/pctl.h
index fd0a1e486..ea3b97823 100644
--- a/src/core/hle/service/pctl/pctl.h
+++ b/src/core/hle/service/pctl/pctl.h
@@ -15,7 +15,7 @@ namespace Service::PCTL {
class PCTL final : public Module::Interface {
public:
explicit PCTL(Core::System& system_, std::shared_ptr<Module> module_, const char* name,
- Capability capability);
+ Capability capability_);
~PCTL() override;
};
diff --git a/src/core/hle/service/pm/pm.cpp b/src/core/hle/service/pm/pm.cpp
index 68736c40c..a43185c44 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 auto process = SearchProcessList(process_list, [](const auto& process) {
- return process->GetProcessID() == Kernel::Process::ProcessIDMin;
+ const std::vector<Kernel::KProcess*>& process_list) {
+ const auto process = SearchProcessList(process_list, [](const auto& proc) {
+ return proc->GetProcessID() == Kernel::KProcess::ProcessIDMin;
});
IPC::ResponseBuilder rb{ctx, 4};
@@ -100,8 +100,8 @@ private:
LOG_DEBUG(Service_PM, "called, title_id={:016X}", title_id);
const auto process =
- SearchProcessList(kernel.GetProcessList(), [title_id](const auto& process) {
- return process->GetTitleID() == title_id;
+ SearchProcessList(kernel.GetProcessList(), [title_id](const auto& proc) {
+ return proc->GetTitleID() == title_id;
});
if (!process.has_value()) {
@@ -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"},
@@ -141,8 +140,8 @@ private:
LOG_DEBUG(Service_PM, "called, process_id={:016X}", process_id);
- const auto process = SearchProcessList(process_list, [process_id](const auto& process) {
- return process->GetProcessID() == process_id;
+ const auto process = SearchProcessList(process_list, [process_id](const auto& proc) {
+ return proc->GetProcessID() == process_id;
});
if (!process.has_value()) {
@@ -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..2c9b2ce6d 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"
@@ -111,16 +111,18 @@ void ServiceFrameworkBase::InstallAsService(SM::ServiceManager& service_manager)
port_installed = true;
}
-void ServiceFrameworkBase::InstallAsNamedPort(Kernel::KernelCore& kernel) {
+Kernel::KClientPort& ServiceFrameworkBase::CreatePort(Kernel::KernelCore& kernel) {
const auto guard = LockService();
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());
+
port_installed = true;
+
+ return port->GetClientPort();
}
void ServiceFrameworkBase::RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n) {
@@ -131,6 +133,16 @@ void ServiceFrameworkBase::RegisterHandlersBase(const FunctionInfoBase* function
}
}
+void ServiceFrameworkBase::RegisterHandlersBaseTipc(const FunctionInfoBase* functions,
+ std::size_t n) {
+ handlers_tipc.reserve(handlers_tipc.size() + n);
+ for (std::size_t i = 0; i < n; ++i) {
+ // Usually this array is sorted by id already, so hint to insert at the end
+ handlers_tipc.emplace_hint(handlers_tipc.cend(), functions[i].expected_header,
+ functions[i]);
+ }
+}
+
void ServiceFrameworkBase::ReportUnimplementedFunction(Kernel::HLERequestContext& ctx,
const FunctionInfoBase* info) {
auto cmd_buf = ctx.CommandBuffer();
@@ -165,33 +177,55 @@ void ServiceFrameworkBase::InvokeRequest(Kernel::HLERequestContext& ctx) {
handler_invoker(this, info->handler_callback, ctx);
}
-ResultCode ServiceFrameworkBase::HandleSyncRequest(Kernel::HLERequestContext& context) {
+void ServiceFrameworkBase::InvokeRequestTipc(Kernel::HLERequestContext& ctx) {
+ boost::container::flat_map<u32, FunctionInfoBase>::iterator itr;
+
+ itr = handlers_tipc.find(ctx.GetCommand());
+
+ const FunctionInfoBase* info = itr == handlers_tipc.end() ? nullptr : &itr->second;
+ if (info == nullptr || info->handler_callback == nullptr) {
+ return ReportUnimplementedFunction(ctx, info);
+ }
+
+ LOG_TRACE(Service, "{}", MakeFunctionString(info->name, GetServiceName(), ctx.CommandBuffer()));
+ handler_invoker(this, info->handler_callback, ctx);
+}
+
+ResultCode ServiceFrameworkBase::HandleSyncRequest(Kernel::KServerSession& session,
+ Kernel::HLERequestContext& ctx) {
const auto guard = LockService();
- switch (context.GetCommandType()) {
- case IPC::CommandType::Close: {
- IPC::ResponseBuilder rb{context, 2};
+ switch (ctx.GetCommandType()) {
+ case IPC::CommandType::Close:
+ case IPC::CommandType::TIPC_Close: {
+ session.Close();
+ IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS);
return IPC::ERR_REMOTE_PROCESS_DEAD;
}
case IPC::CommandType::ControlWithContext:
case IPC::CommandType::Control: {
- system.ServiceManager().InvokeControlRequest(context);
+ system.ServiceManager().InvokeControlRequest(ctx);
break;
}
case IPC::CommandType::RequestWithContext:
case IPC::CommandType::Request: {
- InvokeRequest(context);
+ InvokeRequest(ctx);
break;
}
default:
- UNIMPLEMENTED_MSG("command_type={}", context.GetCommandType());
+ if (ctx.IsTipc()) {
+ InvokeRequestTipc(ctx);
+ break;
+ }
+
+ UNIMPLEMENTED_MSG("command_type={}", ctx.GetCommandType());
}
// If emulation was shutdown, we are closing service threads, do not write the response back to
// memory that may be shutting down as well.
if (system.IsPoweredOn()) {
- context.WriteToOutgoingCommandBuffer(context.GetThread());
+ ctx.WriteToOutgoingCommandBuffer(ctx.GetThread());
}
return RESULT_SUCCESS;
@@ -206,7 +240,7 @@ Services::Services(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system
system.GetFileSystemController().CreateFactories(*system.GetFilesystem(), false);
- SM::ServiceManager::InstallInterfaces(sm, system);
+ system.Kernel().RegisterNamedService("sm:", SM::ServiceManager::InterfaceFactory);
Account::InstallInterfaces(system);
AM::InstallInterfaces(*sm, *nv_flinger, system);
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h
index 916445517..4c048173b 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,10 +20,9 @@ class System;
}
namespace Kernel {
-class ClientPort;
-class ServerPort;
-class ServerSession;
class HLERequestContext;
+class KClientPort;
+class KServerSession;
} // namespace Kernel
namespace Service {
@@ -68,12 +66,19 @@ public:
/// Creates a port pair and registers this service with the given ServiceManager.
void InstallAsService(SM::ServiceManager& service_manager);
- /// Creates a port pair and registers it on the kernel's global port registry.
- void InstallAsNamedPort(Kernel::KernelCore& kernel);
- /// Invokes a service request routine.
+
+ /// Invokes a service request routine using the HIPC protocol.
void InvokeRequest(Kernel::HLERequestContext& ctx);
+
+ /// Invokes a service request routine using the HIPC protocol.
+ void InvokeRequestTipc(Kernel::HLERequestContext& ctx);
+
+ /// Creates a port pair and registers it on the kernel's global port registry.
+ Kernel::KClientPort& CreatePort(Kernel::KernelCore& kernel);
+
/// Handles a synchronization request for the service.
- ResultCode HandleSyncRequest(Kernel::HLERequestContext& context) override;
+ ResultCode HandleSyncRequest(Kernel::KServerSession& session,
+ Kernel::HLERequestContext& context) override;
protected:
/// Member-function pointer type of SyncRequest handlers.
@@ -106,6 +111,7 @@ private:
~ServiceFrameworkBase() override;
void RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n);
+ void RegisterHandlersBaseTipc(const FunctionInfoBase* functions, std::size_t n);
void ReportUnimplementedFunction(Kernel::HLERequestContext& ctx, const FunctionInfoBase* info);
/// Identifier string used to connect to the service.
@@ -120,6 +126,7 @@ private:
/// Function used to safely up-cast pointers to the derived class before invoking a handler.
InvokerFn* handler_invoker;
boost::container::flat_map<u32, FunctionInfoBase> handlers;
+ boost::container::flat_map<u32, FunctionInfoBase> handlers_tipc;
/// Used to gain exclusive access to the service members, e.g. from CoreTiming thread.
Common::SpinLock lock_service;
@@ -148,17 +155,17 @@ protected:
/**
* Constructs a FunctionInfo for a function.
*
- * @param expected_header request header in the command buffer which will trigger dispatch
+ * @param expected_header_ request header in the command buffer which will trigger dispatch
* to this handler
- * @param handler_callback member function in this service which will be called to handle
+ * @param handler_callback_ member function in this service which will be called to handle
* the request
- * @param name human-friendly name for the request. Used mostly for logging purposes.
+ * @param name_ human-friendly name for the request. Used mostly for logging purposes.
*/
- FunctionInfo(u32 expected_header, HandlerFnP<Self> handler_callback, const char* name)
+ FunctionInfo(u32 expected_header_, HandlerFnP<Self> handler_callback_, const char* name_)
: FunctionInfoBase{
- expected_header,
+ expected_header_,
// Type-erase member function pointer by casting it down to the base class.
- static_cast<HandlerFnP<ServiceFrameworkBase>>(handler_callback), name} {}
+ static_cast<HandlerFnP<ServiceFrameworkBase>>(handler_callback_), name_} {}
};
/**
@@ -187,6 +194,20 @@ protected:
RegisterHandlersBase(functions, n);
}
+ /// Registers handlers in the service.
+ template <std::size_t N>
+ void RegisterHandlersTipc(const FunctionInfo (&functions)[N]) {
+ RegisterHandlersTipc(functions, N);
+ }
+
+ /**
+ * Registers handlers in the service. Usually prefer using the other RegisterHandlers
+ * overload in order to avoid needing to specify the array size.
+ */
+ void RegisterHandlersTipc(const FunctionInfo* functions, std::size_t n) {
+ RegisterHandlersBaseTipc(functions, n);
+ }
+
private:
/**
* This function is used to allow invocation of pointers to handlers stored in the base class
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..de530cbfb 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};
@@ -26,15 +26,23 @@ void Controller::CloneCurrentObject(Kernel::HLERequestContext& ctx) {
// TODO(bunnei): This is just creating a new handle to the same Session. I assume this is wrong
// and that we probably want to actually make an entirely new Session, but we still need to
// verify this on hardware.
+
LOG_DEBUG(Service, "called");
+ auto session = ctx.Session()->GetParent();
+
+ // Open a reference to the session to simulate a new one being created.
+ session->Open();
+ session->GetClientSession().Open();
+ session->GetServerSession().Open();
+
IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles};
rb.Push(RESULT_SUCCESS);
- rb.PushMoveObjects(ctx.Session()->GetParent()->Client());
+ rb.PushMoveObjects(session->GetClientSession());
}
void Controller::CloneCurrentObjectEx(Kernel::HLERequestContext& ctx) {
- LOG_WARNING(Service, "(STUBBED) called, using CloneCurrentObject");
+ LOG_DEBUG(Service, "called");
CloneCurrentObject(ctx);
}
@@ -44,7 +52,7 @@ void Controller::QueryPointerBufferSize(Kernel::HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(RESULT_SUCCESS);
- rb.Push<u16>(0x1000);
+ rb.Push<u16>(0x8000);
}
// https://switchbrew.org/wiki/IPC_Marshalling
diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp
index 94608d529..8cc9aee8a 100644
--- a/src/core/hle/service/sm/sm.cpp
+++ b/src/core/hle/service/sm/sm.cpp
@@ -6,15 +6,20 @@
#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_scoped_resource_reservation.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"
namespace Service::SM {
+constexpr ResultCode ERR_NOT_INITIALIZED(ErrorModule::SM, 2);
constexpr ResultCode ERR_ALREADY_REGISTERED(ErrorModule::SM, 4);
constexpr ResultCode ERR_INVALID_NAME(ErrorModule::SM, 6);
constexpr ResultCode ERR_SERVICE_NOT_REGISTERED(ErrorModule::SM, 7);
@@ -31,24 +36,21 @@ static ResultCode ValidateServiceName(const std::string& name) {
LOG_ERROR(Service_SM, "Invalid service name! service={}", name);
return ERR_INVALID_NAME;
}
- if (name.rfind('\0') != std::string::npos) {
- LOG_ERROR(Service_SM, "A non null terminated service was passed");
- return ERR_INVALID_NAME;
- }
return RESULT_SUCCESS;
}
-void ServiceManager::InstallInterfaces(std::shared_ptr<ServiceManager> self, Core::System& system) {
- ASSERT(self->sm_interface.expired());
+Kernel::KClientPort& ServiceManager::InterfaceFactory(ServiceManager& self, Core::System& system) {
+ ASSERT(self.sm_interface.expired());
auto sm = std::make_shared<SM>(self, system);
- sm->InstallAsNamedPort(system.Kernel());
- self->sm_interface = sm;
- self->controller_interface = std::make_unique<Controller>(system);
+ self.sm_interface = sm;
+ self.controller_interface = std::make_unique<Controller>(system);
+
+ return sm->CreatePort(system.Kernel());
}
-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 +59,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 +75,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 +94,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;
/**
@@ -108,50 +106,81 @@ SM::~SM() = default;
void SM::Initialize(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_SM, "called");
+ is_initialized = true;
+
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS);
}
void SM::GetService(Kernel::HLERequestContext& ctx) {
- IPC::RequestParser rp{ctx};
+ auto result = GetServiceImpl(ctx);
+ if (result.Succeeded()) {
+ IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles};
+ rb.Push(result.Code());
+ rb.PushMoveObjects(result.Unwrap());
+ } else {
+ IPC::ResponseBuilder rb{ctx, 2};
+ rb.Push(result.Code());
+ }
+}
+
+void SM::GetServiceTipc(Kernel::HLERequestContext& ctx) {
+ auto result = GetServiceImpl(ctx);
+ IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles};
+ rb.Push(result.Code());
+ rb.PushMoveObjects(result.Succeeded() ? result.Unwrap() : nullptr);
+}
+
+static std::string PopServiceName(IPC::RequestParser& rp) {
auto name_buf = rp.PopRaw<std::array<char, 8>>();
- auto end = std::find(name_buf.begin(), name_buf.end(), '\0');
+ std::string result;
+ for (const auto& c : name_buf) {
+ if (c >= ' ' && c <= '~') {
+ result.push_back(c);
+ }
+ }
+ return result;
+}
- std::string name(name_buf.begin(), end);
+ResultVal<Kernel::KClientSession*> SM::GetServiceImpl(Kernel::HLERequestContext& ctx) {
+ if (!is_initialized) {
+ return ERR_NOT_INITIALIZED;
+ }
- auto client_port = service_manager->GetServicePort(name);
- if (client_port.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);
- if (name.length() == 0)
- return; // LibNX Fix
- UNIMPLEMENTED();
- return;
+ IPC::RequestParser rp{ctx};
+ std::string name(PopServiceName(rp));
+
+ auto result = service_manager.GetServicePort(name);
+ if (result.Failed()) {
+ LOG_ERROR(Service_SM, "called service={} -> error 0x{:08X}", name, result.Code().raw);
+ return result.Code();
}
- auto [client, server] = Kernel::Session::Create(kernel, name);
+ auto* port = result.Unwrap();
+
+ // Kernel::KScopedResourceReservation session_reservation(
+ // kernel.CurrentProcess()->GetResourceLimit(), Kernel::LimitableResource::Sessions);
+ // R_UNLESS(session_reservation.Succeeded(), Kernel::ResultLimitReached);
+
+ auto* session = Kernel::KSession::Create(kernel);
+ session->Initialize(&port->GetClientPort(), std::move(name));
- const auto& server_port = client_port.Unwrap()->GetServerPort();
- if (server_port->GetHLEHandler()) {
- server_port->GetHLEHandler()->ClientConnected(server);
+ // Commit the session reservation.
+ // session_reservation.Commit();
+
+ 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());
- IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles};
- rb.Push(RESULT_SUCCESS);
- rb.PushMoveObjects(std::move(client));
+ LOG_DEBUG(Service_SM, "called service={} -> session={}", name, session->GetId());
+ return MakeResult(&session->GetClientSession());
}
void SM::RegisterService(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
-
- const auto name_buf = rp.PopRaw<std::array<char, 8>>();
- const auto end = std::find(name_buf.begin(), name_buf.end(), '\0');
-
- const std::string name(name_buf.begin(), end);
+ std::string name(PopServiceName(rp));
const auto is_light = static_cast<bool>(rp.PopRaw<u32>());
const auto max_session_count = rp.PopRaw<u32>();
@@ -159,7 +188,7 @@ void SM::RegisterService(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_SM, "called with name={}, max_session_count={}, is_light={}", name,
max_session_count, is_light);
- auto handle = service_manager->RegisterService(name, max_session_count);
+ auto handle = service_manager.RegisterService(name, max_session_count);
if (handle.Failed()) {
LOG_ERROR(Service_SM, "failed to register service with error_code={:08X}",
handle.Code().raw);
@@ -170,33 +199,38 @@ 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) {
IPC::RequestParser rp{ctx};
+ std::string name(PopServiceName(rp));
- const auto name_buf = rp.PopRaw<std::array<char, 8>>();
- const auto end = std::find(name_buf.begin(), name_buf.end(), '\0');
-
- const std::string name(name_buf.begin(), end);
LOG_DEBUG(Service_SM, "called with name={}", name);
IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(service_manager->UnregisterService(name));
+ rb.Push(service_manager.UnregisterService(name));
}
-SM::SM(std::shared_ptr<ServiceManager> service_manager_, Core::System& system_)
+SM::SM(ServiceManager& service_manager_, Core::System& system_)
: ServiceFramework{system_, "sm:", 4},
- service_manager{std::move(service_manager_)}, kernel{system_.Kernel()} {
- static const FunctionInfo functions[] = {
+ service_manager{service_manager_}, kernel{system_.Kernel()} {
+ RegisterHandlers({
{0, &SM::Initialize, "Initialize"},
{1, &SM::GetService, "GetService"},
{2, &SM::RegisterService, "RegisterService"},
{3, &SM::UnregisterService, "UnregisterService"},
{4, nullptr, "DetachClient"},
- };
- RegisterHandlers(functions);
+ });
+ RegisterHandlersTipc({
+ {0, &SM::Initialize, "Initialize"},
+ {1, &SM::GetServiceTipc, "GetService"},
+ {2, &SM::RegisterService, "RegisterService"},
+ {3, &SM::UnregisterService, "UnregisterService"},
+ {4, nullptr, "DetachClient"},
+ });
}
} // namespace Service::SM
diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h
index 3f46ae44f..60f0b3f8a 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
@@ -35,31 +34,33 @@ class Controller;
/// Interface to "sm:" service
class SM final : public ServiceFramework<SM> {
public:
- explicit SM(std::shared_ptr<ServiceManager> service_manager_, Core::System& system_);
+ explicit SM(ServiceManager& service_manager_, Core::System& system_);
~SM() override;
private:
void Initialize(Kernel::HLERequestContext& ctx);
void GetService(Kernel::HLERequestContext& ctx);
+ void GetServiceTipc(Kernel::HLERequestContext& ctx);
void RegisterService(Kernel::HLERequestContext& ctx);
void UnregisterService(Kernel::HLERequestContext& ctx);
- std::shared_ptr<ServiceManager> service_manager;
+ ResultVal<Kernel::KClientSession*> GetServiceImpl(Kernel::HLERequestContext& ctx);
+
+ ServiceManager& service_manager;
+ bool is_initialized{};
Kernel::KernelCore& kernel;
};
class ServiceManager {
public:
- static void InstallInterfaces(std::shared_ptr<ServiceManager> self, Core::System& system);
+ static Kernel::KClientPort& InterfaceFactory(ServiceManager& self, Core::System& system);
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 +69,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 +82,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/ssl/ssl.cpp b/src/core/hle/service/ssl/ssl.cpp
index dc2baca4a..3b072f6bc 100644
--- a/src/core/hle/service/ssl/ssl.cpp
+++ b/src/core/hle/service/ssl/ssl.cpp
@@ -10,6 +10,11 @@
namespace Service::SSL {
+enum class CertificateFormat : u32 {
+ Pem = 1,
+ Der = 2,
+};
+
class ISslConnection final : public ServiceFramework<ISslConnection> {
public:
explicit ISslConnection(Core::System& system_) : ServiceFramework{system_, "ISslConnection"} {
@@ -58,8 +63,8 @@ public:
{1, nullptr, "GetOption"},
{2, &ISslContext::CreateConnection, "CreateConnection"},
{3, nullptr, "GetConnectionCount"},
- {4, nullptr, "ImportServerPki"},
- {5, nullptr, "ImportClientPki"},
+ {4, &ISslContext::ImportServerPki, "ImportServerPki"},
+ {5, &ISslContext::ImportClientPki, "ImportClientPki"},
{6, nullptr, "RemoveServerPki"},
{7, nullptr, "RemoveClientPki"},
{8, nullptr, "RegisterInternalPki"},
@@ -94,6 +99,39 @@ private:
rb.Push(RESULT_SUCCESS);
rb.PushIpcInterface<ISslConnection>(system);
}
+
+ void ImportServerPki(Kernel::HLERequestContext& ctx) {
+ IPC::RequestParser rp{ctx};
+ const auto certificate_format = rp.PopEnum<CertificateFormat>();
+ const auto pkcs_12_certificates = ctx.ReadBuffer(0);
+
+ constexpr u64 server_id = 0;
+
+ LOG_WARNING(Service_SSL, "(STUBBED) called, certificate_format={}", certificate_format);
+
+ IPC::ResponseBuilder rb{ctx, 4};
+ rb.Push(RESULT_SUCCESS);
+ rb.Push(server_id);
+ }
+
+ void ImportClientPki(Kernel::HLERequestContext& ctx) {
+ const auto pkcs_12_certificate = ctx.ReadBuffer(0);
+ const auto ascii_password = [&ctx] {
+ if (ctx.CanReadBuffer(1)) {
+ return ctx.ReadBuffer(1);
+ }
+
+ return std::vector<u8>{};
+ }();
+
+ constexpr u64 client_id = 0;
+
+ LOG_WARNING(Service_SSL, "(STUBBED) called");
+
+ IPC::ResponseBuilder rb{ctx, 4};
+ rb.Push(RESULT_SUCCESS);
+ rb.Push(client_id);
+ }
};
class SSL final : public ServiceFramework<SSL> {
diff --git a/src/core/hle/service/time/ephemeral_network_system_clock_core.h b/src/core/hle/service/time/ephemeral_network_system_clock_core.h
index 4c6cdef86..d12cb5335 100644
--- a/src/core/hle/service/time/ephemeral_network_system_clock_core.h
+++ b/src/core/hle/service/time/ephemeral_network_system_clock_core.h
@@ -10,8 +10,8 @@ namespace Service::Time::Clock {
class EphemeralNetworkSystemClockCore final : public SystemClockCore {
public:
- explicit EphemeralNetworkSystemClockCore(SteadyClockCore& steady_clock_core)
- : SystemClockCore{steady_clock_core} {}
+ explicit EphemeralNetworkSystemClockCore(SteadyClockCore& steady_clock_core_)
+ : SystemClockCore{steady_clock_core_} {}
};
} // namespace Service::Time::Clock
diff --git a/src/core/hle/service/time/local_system_clock_context_writer.h b/src/core/hle/service/time/local_system_clock_context_writer.h
index 7050844c6..490d0ef3e 100644
--- a/src/core/hle/service/time/local_system_clock_context_writer.h
+++ b/src/core/hle/service/time/local_system_clock_context_writer.h
@@ -12,8 +12,8 @@ namespace Service::Time::Clock {
class LocalSystemClockContextWriter final : public SystemClockContextUpdateCallback {
public:
- explicit LocalSystemClockContextWriter(SharedMemory& shared_memory)
- : SystemClockContextUpdateCallback{}, shared_memory{shared_memory} {}
+ explicit LocalSystemClockContextWriter(SharedMemory& shared_memory_)
+ : SystemClockContextUpdateCallback{}, shared_memory{shared_memory_} {}
protected:
ResultCode Update() override {
diff --git a/src/core/hle/service/time/network_system_clock_context_writer.h b/src/core/hle/service/time/network_system_clock_context_writer.h
index 94d8788ff..e2920b8eb 100644
--- a/src/core/hle/service/time/network_system_clock_context_writer.h
+++ b/src/core/hle/service/time/network_system_clock_context_writer.h
@@ -12,8 +12,8 @@ namespace Service::Time::Clock {
class NetworkSystemClockContextWriter final : public SystemClockContextUpdateCallback {
public:
- explicit NetworkSystemClockContextWriter(SharedMemory& shared_memory)
- : SystemClockContextUpdateCallback{}, shared_memory{shared_memory} {}
+ explicit NetworkSystemClockContextWriter(SharedMemory& shared_memory_)
+ : SystemClockContextUpdateCallback{}, shared_memory{shared_memory_} {}
protected:
ResultCode Update() override {
diff --git a/src/core/hle/service/time/standard_local_system_clock_core.h b/src/core/hle/service/time/standard_local_system_clock_core.h
index 8c1882eb1..6320c7af1 100644
--- a/src/core/hle/service/time/standard_local_system_clock_core.h
+++ b/src/core/hle/service/time/standard_local_system_clock_core.h
@@ -10,8 +10,8 @@ namespace Service::Time::Clock {
class StandardLocalSystemClockCore final : public SystemClockCore {
public:
- explicit StandardLocalSystemClockCore(SteadyClockCore& steady_clock_core)
- : SystemClockCore{steady_clock_core} {}
+ explicit StandardLocalSystemClockCore(SteadyClockCore& steady_clock_core_)
+ : SystemClockCore{steady_clock_core_} {}
};
} // namespace Service::Time::Clock
diff --git a/src/core/hle/service/time/standard_network_system_clock_core.h b/src/core/hle/service/time/standard_network_system_clock_core.h
index c993bdf79..9d0aeaedb 100644
--- a/src/core/hle/service/time/standard_network_system_clock_core.h
+++ b/src/core/hle/service/time/standard_network_system_clock_core.h
@@ -16,21 +16,21 @@ namespace Service::Time::Clock {
class StandardNetworkSystemClockCore final : public SystemClockCore {
public:
- explicit StandardNetworkSystemClockCore(SteadyClockCore& steady_clock_core)
- : SystemClockCore{steady_clock_core} {}
+ explicit StandardNetworkSystemClockCore(SteadyClockCore& steady_clock_core_)
+ : SystemClockCore{steady_clock_core_} {}
void SetStandardNetworkClockSufficientAccuracy(TimeSpanType value) {
standard_network_clock_sufficient_accuracy = value;
}
bool IsStandardNetworkSystemClockAccuracySufficient(Core::System& system) const {
- SystemClockContext context{};
- if (GetClockContext(system, context) != RESULT_SUCCESS) {
+ SystemClockContext clock_ctx{};
+ if (GetClockContext(system, clock_ctx) != RESULT_SUCCESS) {
return {};
}
s64 span{};
- if (context.steady_time_point.GetSpanBetween(
+ if (clock_ctx.steady_time_point.GetSpanBetween(
GetSteadyClockCore().GetCurrentTimePoint(system), span) != RESULT_SUCCESS) {
return {};
}
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..41bc01abd 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"
@@ -12,15 +11,15 @@
namespace Service::Time::Clock {
StandardUserSystemClockCore::StandardUserSystemClockCore(
- StandardLocalSystemClockCore& local_system_clock_core,
- StandardNetworkSystemClockCore& network_system_clock_core, Core::System& system)
- : 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();
+ StandardLocalSystemClockCore& local_system_clock_core_,
+ StandardNetworkSystemClockCore& network_system_clock_core_, Core::System& system_)
+ : SystemClockCore(local_system_clock_core_.GetSteadyClockCore()),
+ local_system_clock_core{local_system_clock_core_},
+ network_system_clock_core{network_system_clock_core_},
+ 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,
@@ -36,13 +35,13 @@ ResultCode StandardUserSystemClockCore::SetAutomaticCorrectionEnabled(Core::Syst
}
ResultCode StandardUserSystemClockCore::GetClockContext(Core::System& system,
- SystemClockContext& context) const {
+ SystemClockContext& ctx) const {
if (const ResultCode result{ApplyAutomaticCorrection(system, false)};
result != RESULT_SUCCESS) {
return result;
}
- return local_system_clock_core.GetClockContext(system, context);
+ return local_system_clock_core.GetClockContext(system, ctx);
}
ResultCode StandardUserSystemClockCore::Flush(const SystemClockContext&) {
@@ -65,13 +64,13 @@ ResultCode StandardUserSystemClockCore::ApplyAutomaticCorrection(Core::System& s
return ERROR_UNINITIALIZED_CLOCK;
}
- SystemClockContext context{};
- if (const ResultCode result{network_system_clock_core.GetClockContext(system, context)};
+ SystemClockContext ctx{};
+ if (const ResultCode result{network_system_clock_core.GetClockContext(system, ctx)};
result != RESULT_SUCCESS) {
return result;
}
- local_system_clock_core.SetClockContext(context);
+ local_system_clock_core.SetClockContext(ctx);
return RESULT_SUCCESS;
}
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..bf9ec5e42 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"
@@ -22,13 +23,13 @@ class StandardNetworkSystemClockCore;
class StandardUserSystemClockCore final : public SystemClockCore {
public:
- StandardUserSystemClockCore(StandardLocalSystemClockCore& local_system_clock_core,
- StandardNetworkSystemClockCore& network_system_clock_core,
- Core::System& system);
+ StandardUserSystemClockCore(StandardLocalSystemClockCore& local_system_clock_core_,
+ StandardNetworkSystemClockCore& network_system_clock_core_,
+ Core::System& system_);
ResultCode SetAutomaticCorrectionEnabled(Core::System& system, bool value);
- ResultCode GetClockContext(Core::System& system, SystemClockContext& context) const override;
+ ResultCode GetClockContext(Core::System& system, SystemClockContext& ctx) const override;
bool IsAutomaticCorrectionEnabled() const {
return auto_correction_enabled;
@@ -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/system_clock_core.cpp b/src/core/hle/service/time/system_clock_core.cpp
index 46fc8c6c3..2ef442b56 100644
--- a/src/core/hle/service/time/system_clock_core.cpp
+++ b/src/core/hle/service/time/system_clock_core.cpp
@@ -8,8 +8,8 @@
namespace Service::Time::Clock {
-SystemClockCore::SystemClockCore(SteadyClockCore& steady_clock_core)
- : steady_clock_core{steady_clock_core} {
+SystemClockCore::SystemClockCore(SteadyClockCore& steady_clock_core_)
+ : steady_clock_core{steady_clock_core_} {
context.steady_time_point.clock_source_id = steady_clock_core.GetClockSourceId();
}
diff --git a/src/core/hle/service/time/system_clock_core.h b/src/core/hle/service/time/system_clock_core.h
index 82a8b79ff..b8e6122bf 100644
--- a/src/core/hle/service/time/system_clock_core.h
+++ b/src/core/hle/service/time/system_clock_core.h
@@ -21,7 +21,7 @@ class SystemClockContextUpdateCallback;
class SystemClockCore {
public:
- explicit SystemClockCore(SteadyClockCore& steady_clock_core);
+ explicit SystemClockCore(SteadyClockCore& steady_clock_core_);
virtual ~SystemClockCore();
SteadyClockCore& GetSteadyClockCore() const {
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_manager.cpp b/src/core/hle/service/time/time_manager.cpp
index fe01a3739..4f9684de8 100644
--- a/src/core/hle/service/time/time_manager.cpp
+++ b/src/core/hle/service/time/time_manager.cpp
@@ -223,7 +223,7 @@ struct TimeManager::Impl final {
TimeZone::TimeZoneContentManager time_zone_content_manager;
};
-TimeManager::TimeManager(Core::System& system) : system{system} {}
+TimeManager::TimeManager(Core::System& system_) : system{system_} {}
TimeManager::~TimeManager() = default;
diff --git a/src/core/hle/service/time/time_manager.h b/src/core/hle/service/time/time_manager.h
index 4db8cc0e1..3af868d87 100644
--- a/src/core/hle/service/time/time_manager.h
+++ b/src/core/hle/service/time/time_manager.h
@@ -30,7 +30,7 @@ class NetworkSystemClockContextWriter;
class TimeManager final {
public:
- explicit TimeManager(Core::System& system);
+ explicit TimeManager(Core::System& system_);
~TimeManager();
void Initialize();
diff --git a/src/core/hle/service/time/time_sharedmemory.cpp b/src/core/hle/service/time/time_sharedmemory.cpp
index 018ce94ed..176ad0eee 100644
--- a/src/core/hle/service/time/time_sharedmemory.cpp
+++ b/src/core/hle/service/time/time_sharedmemory.cpp
@@ -15,17 +15,12 @@ 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);
+SharedMemory::SharedMemory(Core::System& system_) : system(system_) {
+ 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..d471b5d18 100644
--- a/src/core/hle/service/time/time_sharedmemory.h
+++ b/src/core/hle/service/time/time_sharedmemory.h
@@ -14,12 +14,9 @@ namespace Service::Time {
class SharedMemory final {
public:
- explicit SharedMemory(Core::System& system);
+ 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/time/time_zone_content_manager.cpp b/src/core/hle/service/time/time_zone_content_manager.cpp
index 3c8e71a3c..57f71e6f0 100644
--- a/src/core/hle/service/time/time_zone_content_manager.cpp
+++ b/src/core/hle/service/time/time_zone_content_manager.cpp
@@ -68,8 +68,8 @@ static std::vector<std::string> BuildLocationNameCache(Core::System& system) {
return location_name_cache;
}
-TimeZoneContentManager::TimeZoneContentManager(Core::System& system)
- : system{system}, location_name_cache{BuildLocationNameCache(system)} {}
+TimeZoneContentManager::TimeZoneContentManager(Core::System& system_)
+ : system{system_}, location_name_cache{BuildLocationNameCache(system)} {}
void TimeZoneContentManager::Initialize(TimeManager& time_manager) {
std::string location_name;
diff --git a/src/core/hle/service/time/time_zone_content_manager.h b/src/core/hle/service/time/time_zone_content_manager.h
index 52dd1a020..cfa601084 100644
--- a/src/core/hle/service/time/time_zone_content_manager.h
+++ b/src/core/hle/service/time/time_zone_content_manager.h
@@ -21,7 +21,7 @@ namespace Service::Time::TimeZone {
class TimeZoneContentManager final {
public:
- explicit TimeZoneContentManager(Core::System& system);
+ explicit TimeZoneContentManager(Core::System& system_);
void Initialize(TimeManager& time_manager);
diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp
index ac9e87338..0dd342dbf 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)
+ : display_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..166f2a4cc 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,24 +25,21 @@ 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.
///
/// @param id The unique ID for this display.
- /// @param name The name for this display.
+ /// @param name_ The name for this display.
///
- Display(u64 id, std::string name, Core::System& system);
+ 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;
+ return display_id;
}
/// Gets the name of this display
@@ -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();
@@ -98,11 +96,11 @@ public:
const Layer* FindLayer(u64 layer_id) const;
private:
- u64 id;
+ u64 display_id;
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/layer/vi_layer.cpp b/src/core/hle/service/vi/layer/vi_layer.cpp
index 954225c26..9bc382587 100644
--- a/src/core/hle/service/vi/layer/vi_layer.cpp
+++ b/src/core/hle/service/vi/layer/vi_layer.cpp
@@ -6,7 +6,7 @@
namespace Service::VI {
-Layer::Layer(u64 id, NVFlinger::BufferQueue& queue) : id{id}, buffer_queue{queue} {}
+Layer::Layer(u64 id, NVFlinger::BufferQueue& queue) : layer_id{id}, buffer_queue{queue} {}
Layer::~Layer() = default;
diff --git a/src/core/hle/service/vi/layer/vi_layer.h b/src/core/hle/service/vi/layer/vi_layer.h
index c6bfd01f6..ebdd85505 100644
--- a/src/core/hle/service/vi/layer/vi_layer.h
+++ b/src/core/hle/service/vi/layer/vi_layer.h
@@ -31,7 +31,7 @@ public:
/// Gets the ID for this layer.
u64 GetID() const {
- return id;
+ return layer_id;
}
/// Gets a reference to the buffer queue this layer is using.
@@ -45,7 +45,7 @@ public:
}
private:
- u64 id;
+ u64 layer_id;
NVFlinger::BufferQueue& buffer_queue;
};
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp
index 7ae07d072..fdd2b4b4f 100644
--- a/src/core/hle/service/vi/vi.cpp
+++ b/src/core/hle/service/vi/vi.cpp
@@ -212,7 +212,7 @@ private:
class IGBPConnectRequestParcel : public Parcel {
public:
- explicit IGBPConnectRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) {
+ explicit IGBPConnectRequestParcel(std::vector<u8> buffer_) : Parcel(std::move(buffer_)) {
Deserialize();
}
@@ -274,8 +274,8 @@ private:
class IGBPSetPreallocatedBufferRequestParcel : public Parcel {
public:
- explicit IGBPSetPreallocatedBufferRequestParcel(std::vector<u8> buffer)
- : Parcel(std::move(buffer)) {
+ explicit IGBPSetPreallocatedBufferRequestParcel(std::vector<u8> buffer_)
+ : Parcel(std::move(buffer_)) {
Deserialize();
}
@@ -312,7 +312,7 @@ protected:
class IGBPCancelBufferRequestParcel : public Parcel {
public:
- explicit IGBPCancelBufferRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) {
+ explicit IGBPCancelBufferRequestParcel(std::vector<u8> buffer_) : Parcel(std::move(buffer_)) {
Deserialize();
}
@@ -338,7 +338,7 @@ protected:
class IGBPDequeueBufferRequestParcel : public Parcel {
public:
- explicit IGBPDequeueBufferRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) {
+ explicit IGBPDequeueBufferRequestParcel(std::vector<u8> buffer_) : Parcel(std::move(buffer_)) {
Deserialize();
}
@@ -360,8 +360,8 @@ public:
class IGBPDequeueBufferResponseParcel : public Parcel {
public:
- explicit IGBPDequeueBufferResponseParcel(u32 slot, Service::Nvidia::MultiFence& multi_fence)
- : slot(slot), multi_fence(multi_fence) {}
+ explicit IGBPDequeueBufferResponseParcel(u32 slot_, Nvidia::MultiFence& multi_fence_)
+ : slot(slot_), multi_fence(multi_fence_) {}
protected:
void SerializeData() override {
@@ -377,7 +377,7 @@ protected:
class IGBPRequestBufferRequestParcel : public Parcel {
public:
- explicit IGBPRequestBufferRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) {
+ explicit IGBPRequestBufferRequestParcel(std::vector<u8> buffer_) : Parcel(std::move(buffer_)) {
Deserialize();
}
@@ -391,7 +391,7 @@ public:
class IGBPRequestBufferResponseParcel : public Parcel {
public:
- explicit IGBPRequestBufferResponseParcel(NVFlinger::IGBPBuffer buffer) : buffer(buffer) {}
+ explicit IGBPRequestBufferResponseParcel(NVFlinger::IGBPBuffer buffer_) : buffer(buffer_) {}
~IGBPRequestBufferResponseParcel() override = default;
protected:
@@ -408,7 +408,7 @@ protected:
class IGBPQueueBufferRequestParcel : public Parcel {
public:
- explicit IGBPQueueBufferRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) {
+ explicit IGBPQueueBufferRequestParcel(std::vector<u8> buffer_) : Parcel(std::move(buffer_)) {
Deserialize();
}
@@ -470,7 +470,7 @@ private:
class IGBPQueryRequestParcel : public Parcel {
public:
- explicit IGBPQueryRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) {
+ explicit IGBPQueryRequestParcel(std::vector<u8> buffer_) : Parcel(std::move(buffer_)) {
Deserialize();
}
@@ -484,7 +484,7 @@ public:
class IGBPQueryResponseParcel : public Parcel {
public:
- explicit IGBPQueryResponseParcel(u32 value) : value(value) {}
+ explicit IGBPQueryResponseParcel(u32 value_) : value{value_} {}
~IGBPQueryResponseParcel() override = default;
protected:
@@ -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;