summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/am
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/hle/service/am/am.cpp127
-rw-r--r--src/core/hle/service/am/am.h32
-rw-r--r--src/core/hle/service/am/applet_ae.h2
-rw-r--r--src/core/hle/service/am/applet_oe.h2
-rw-r--r--src/core/hle/service/am/applets/applet_profile_select.cpp2
-rw-r--r--src/core/hle/service/am/applets/applet_web_browser.cpp10
-rw-r--r--src/core/hle/service/am/applets/applets.cpp41
-rw-r--r--src/core/hle/service/am/applets/applets.h10
8 files changed, 132 insertions, 94 deletions
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index a538f82e3..eccdcc20d 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -16,9 +16,7 @@
#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/service/acc/profile_manager.h"
#include "core/hle/service/am/am.h"
@@ -254,8 +252,9 @@ IDebugFunctions::IDebugFunctions(Core::System& system_)
IDebugFunctions::~IDebugFunctions() = default;
ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nvflinger_)
- : ServiceFramework{system_, "ISelfController"}, nvflinger{nvflinger_},
- launchable_event{system.Kernel()}, accumulated_suspended_tick_changed_event{system.Kernel()} {
+ : ServiceFramework{system_, "ISelfController"}, nvflinger{nvflinger_}, service_context{
+ system,
+ "ISelfController"} {
// clang-format off
static const FunctionInfo functions[] = {
{0, &ISelfController::Exit, "Exit"},
@@ -275,12 +274,14 @@ ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nv
{18, nullptr, "SetRequiresCaptureButtonShortPressedMessage"},
{19, &ISelfController::SetAlbumImageOrientation, "SetAlbumImageOrientation"},
{20, nullptr, "SetDesirableKeyboardLayout"},
+ {21, nullptr, "GetScreenShotProgramId"},
{40, &ISelfController::CreateManagedDisplayLayer, "CreateManagedDisplayLayer"},
{41, nullptr, "IsSystemBufferSharingEnabled"},
{42, nullptr, "GetSystemSharedLayerHandle"},
{43, nullptr, "GetSystemSharedBufferHandle"},
{44, &ISelfController::CreateManagedDisplaySeparableLayer, "CreateManagedDisplaySeparableLayer"},
{45, nullptr, "SetManagedDisplayLayerSeparationMode"},
+ {46, nullptr, "SetRecordingLayerCompositionEnabled"},
{50, &ISelfController::SetHandlesRequestToDisplay, "SetHandlesRequestToDisplay"},
{51, nullptr, "ApproveToDisplay"},
{60, nullptr, "OverrideAutoSleepTimeAndDimmingTime"},
@@ -302,15 +303,14 @@ ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nv
{100, &ISelfController::SetAlbumImageTakenNotificationEnabled, "SetAlbumImageTakenNotificationEnabled"},
{110, nullptr, "SetApplicationAlbumUserData"},
{120, nullptr, "SaveCurrentScreenshot"},
+ {130, nullptr, "SetRecordVolumeMuted"},
{1000, nullptr, "GetDebugStorageChannel"},
};
// clang-format on
RegisterHandlers(functions);
- Kernel::KAutoObject::Create(std::addressof(launchable_event));
-
- launchable_event.Initialize("ISelfController:LaunchableEvent");
+ launchable_event = service_context.CreateEvent("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
@@ -318,21 +318,23 @@ ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nv
// suspended if the event has previously been created by a call to
// GetAccumulatedSuspendedTickChangedEvent.
- 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();
+ accumulated_suspended_tick_changed_event =
+ service_context.CreateEvent("ISelfController:AccumulatedSuspendedTickChangedEvent");
+ accumulated_suspended_tick_changed_event->GetWritableEvent().Signal();
}
-ISelfController::~ISelfController() = default;
+ISelfController::~ISelfController() {
+ service_context.CloseEvent(launchable_event);
+ service_context.CloseEvent(accumulated_suspended_tick_changed_event);
+}
void ISelfController::Exit(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_AM, "called");
- system.Shutdown();
-
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
+
+ system.Exit();
}
void ISelfController::LockExit(Kernel::HLERequestContext& ctx) {
@@ -380,11 +382,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(ResultSuccess);
- rb.PushCopyObjects(launchable_event.GetReadableEvent());
+ rb.PushCopyObjects(launchable_event->GetReadableEvent());
}
void ISelfController::SetScreenShotPermission(Kernel::HLERequestContext& ctx) {
@@ -563,7 +565,7 @@ void ISelfController::GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequest
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(ResultSuccess);
- rb.PushCopyObjects(accumulated_suspended_tick_changed_event.GetReadableEvent());
+ rb.PushCopyObjects(accumulated_suspended_tick_changed_event->GetReadableEvent());
}
void ISelfController::SetAlbumImageTakenNotificationEnabled(Kernel::HLERequestContext& ctx) {
@@ -581,40 +583,39 @@ void ISelfController::SetAlbumImageTakenNotificationEnabled(Kernel::HLERequestCo
rb.Push(ResultSuccess);
}
-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(Core::System& system)
+ : service_context{system, "AppletMessageQueue"} {
+ on_new_message = service_context.CreateEvent("AMMessageQueue:OnMessageReceived");
+ on_operation_mode_changed = service_context.CreateEvent("AMMessageQueue:OperationModeChanged");
}
-AppletMessageQueue::~AppletMessageQueue() = default;
+AppletMessageQueue::~AppletMessageQueue() {
+ service_context.CloseEvent(on_new_message);
+ service_context.CloseEvent(on_operation_mode_changed);
+}
Kernel::KReadableEvent& AppletMessageQueue::GetMessageReceiveEvent() {
- return on_new_message.GetReadableEvent();
+ return on_new_message->GetReadableEvent();
}
Kernel::KReadableEvent& AppletMessageQueue::GetOperationModeChangedEvent() {
- return on_operation_mode_changed.GetReadableEvent();
+ 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;
}
@@ -634,7 +635,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_,
@@ -683,6 +684,7 @@ ICommonStateGetter::ICommonStateGetter(Core::System& system_,
{91, nullptr, "GetCurrentPerformanceConfiguration"},
{100, nullptr, "SetHandlingHomeButtonShortPressedEnabled"},
{110, nullptr, "OpenMyGpuErrorHandler"},
+ {120, nullptr, "GetAppletLaunchedHistory"},
{200, nullptr, "GetOperationModeSystemInfo"},
{300, nullptr, "GetSettingsPlatformRegion"},
{400, nullptr, "ActivateMigrationService"},
@@ -1268,9 +1270,8 @@ void ILibraryAppletCreator::CreateHandleStorage(Kernel::HLERequestContext& ctx)
}
IApplicationFunctions::IApplicationFunctions(Core::System& system_)
- : ServiceFramework{system_, "IApplicationFunctions"}, gpu_error_detected_event{system.Kernel()},
- friend_invitation_storage_channel_event{system.Kernel()},
- health_warning_disappeared_system_event{system.Kernel()} {
+ : ServiceFramework{system_, "IApplicationFunctions"}, service_context{system,
+ "IApplicationFunctions"} {
// clang-format off
static const FunctionInfo functions[] = {
{1, &IApplicationFunctions::PopLaunchParameter, "PopLaunchParameter"},
@@ -1322,7 +1323,7 @@ IApplicationFunctions::IApplicationFunctions(Core::System& system_)
{131, nullptr, "SetDelayTimeToAbortOnGpuError"},
{140, &IApplicationFunctions::GetFriendInvitationStorageChannelEvent, "GetFriendInvitationStorageChannelEvent"},
{141, &IApplicationFunctions::TryPopFromFriendInvitationStorageChannel, "TryPopFromFriendInvitationStorageChannel"},
- {150, nullptr, "GetNotificationStorageChannelEvent"},
+ {150, &IApplicationFunctions::GetNotificationStorageChannelEvent, "GetNotificationStorageChannelEvent"},
{151, nullptr, "TryPopFromNotificationStorageChannel"},
{160, &IApplicationFunctions::GetHealthWarningDisappearedSystemEvent, "GetHealthWarningDisappearedSystemEvent"},
{170, nullptr, "SetHdcpAuthenticationActivated"},
@@ -1338,18 +1339,22 @@ IApplicationFunctions::IApplicationFunctions(Core::System& system_)
RegisterHandlers(functions);
- 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");
+ gpu_error_detected_event =
+ service_context.CreateEvent("IApplicationFunctions:GpuErrorDetectedSystemEvent");
+ friend_invitation_storage_channel_event =
+ service_context.CreateEvent("IApplicationFunctions:FriendInvitationStorageChannelEvent");
+ notification_storage_channel_event =
+ service_context.CreateEvent("IApplicationFunctions:NotificationStorageChannelEvent");
+ health_warning_disappeared_system_event =
+ service_context.CreateEvent("IApplicationFunctions:HealthWarningDisappearedSystemEvent");
}
-IApplicationFunctions::~IApplicationFunctions() = default;
+IApplicationFunctions::~IApplicationFunctions() {
+ service_context.CloseEvent(gpu_error_detected_event);
+ service_context.CloseEvent(friend_invitation_storage_channel_event);
+ service_context.CloseEvent(notification_storage_channel_event);
+ service_context.CloseEvent(health_warning_disappeared_system_event);
+}
void IApplicationFunctions::EnableApplicationCrashReport(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");
@@ -1743,7 +1748,7 @@ void IApplicationFunctions::GetGpuErrorDetectedSystemEvent(Kernel::HLERequestCon
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(ResultSuccess);
- rb.PushCopyObjects(gpu_error_detected_event.GetReadableEvent());
+ rb.PushCopyObjects(gpu_error_detected_event->GetReadableEvent());
}
void IApplicationFunctions::GetFriendInvitationStorageChannelEvent(Kernel::HLERequestContext& ctx) {
@@ -1751,7 +1756,7 @@ void IApplicationFunctions::GetFriendInvitationStorageChannelEvent(Kernel::HLERe
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(ResultSuccess);
- rb.PushCopyObjects(friend_invitation_storage_channel_event.GetReadableEvent());
+ rb.PushCopyObjects(friend_invitation_storage_channel_event->GetReadableEvent());
}
void IApplicationFunctions::TryPopFromFriendInvitationStorageChannel(
@@ -1762,17 +1767,25 @@ void IApplicationFunctions::TryPopFromFriendInvitationStorageChannel(
rb.Push(ERR_NO_DATA_IN_CHANNEL);
}
+void IApplicationFunctions::GetNotificationStorageChannelEvent(Kernel::HLERequestContext& ctx) {
+ LOG_DEBUG(Service_AM, "called");
+
+ IPC::ResponseBuilder rb{ctx, 2, 1};
+ rb.Push(ResultSuccess);
+ rb.PushCopyObjects(notification_storage_channel_event->GetReadableEvent());
+}
+
void IApplicationFunctions::GetHealthWarningDisappearedSystemEvent(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_AM, "called");
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(ResultSuccess);
- 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,
Core::System& system) {
- auto message_queue = std::make_shared<AppletMessageQueue>(system.Kernel());
+ auto message_queue = std::make_shared<AppletMessageQueue>(system);
// Needed on game boot
message_queue->PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged);
@@ -1785,8 +1798,8 @@ void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger
}
IHomeMenuFunctions::IHomeMenuFunctions(Core::System& system_)
- : ServiceFramework{system_, "IHomeMenuFunctions"}, pop_from_general_channel_event{
- system.Kernel()} {
+ : ServiceFramework{system_, "IHomeMenuFunctions"}, service_context{system,
+ "IHomeMenuFunctions"} {
// clang-format off
static const FunctionInfo functions[] = {
{10, &IHomeMenuFunctions::RequestToGetForeground, "RequestToGetForeground"},
@@ -1807,11 +1820,13 @@ IHomeMenuFunctions::IHomeMenuFunctions(Core::System& system_)
RegisterHandlers(functions);
- Kernel::KAutoObject::Create(std::addressof(pop_from_general_channel_event));
- pop_from_general_channel_event.Initialize("IHomeMenuFunctions:PopFromGeneralChannelEvent");
+ pop_from_general_channel_event =
+ service_context.CreateEvent("IHomeMenuFunctions:PopFromGeneralChannelEvent");
}
-IHomeMenuFunctions::~IHomeMenuFunctions() = default;
+IHomeMenuFunctions::~IHomeMenuFunctions() {
+ service_context.CloseEvent(pop_from_general_channel_event);
+}
void IHomeMenuFunctions::RequestToGetForeground(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_AM, "(STUBBED) called");
@@ -1825,7 +1840,7 @@ void IHomeMenuFunctions::GetPopFromGeneralChannelEvent(Kernel::HLERequestContext
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(ResultSuccess);
- 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 184030a8e..202d20757 100644
--- a/src/core/hle/service/am/am.h
+++ b/src/core/hle/service/am/am.h
@@ -8,7 +8,7 @@
#include <memory>
#include <queue>
-#include "core/hle/kernel/k_event.h"
+#include "core/hle/service/kernel_helpers.h"
#include "core/hle/service/service.h"
namespace Kernel {
@@ -53,7 +53,7 @@ public:
PerformanceModeChanged = 31,
};
- explicit AppletMessageQueue(Kernel::KernelCore& kernel);
+ explicit AppletMessageQueue(Core::System& system);
~AppletMessageQueue();
Kernel::KReadableEvent& GetMessageReceiveEvent();
@@ -66,9 +66,12 @@ public:
void OperationModeChanged();
private:
+ KernelHelpers::ServiceContext service_context;
+
+ Kernel::KEvent* on_new_message;
+ Kernel::KEvent* on_operation_mode_changed;
+
std::queue<AppletMessage> messages;
- Kernel::KEvent on_new_message;
- Kernel::KEvent on_operation_mode_changed;
};
class IWindowController final : public ServiceFramework<IWindowController> {
@@ -156,8 +159,11 @@ private:
};
NVFlinger::NVFlinger& nvflinger;
- Kernel::KEvent launchable_event;
- Kernel::KEvent accumulated_suspended_tick_changed_event;
+
+ KernelHelpers::ServiceContext service_context;
+
+ Kernel::KEvent* launchable_event;
+ Kernel::KEvent* accumulated_suspended_tick_changed_event;
u32 idle_time_detection_extension = 0;
u64 num_fatal_sections_entered = 0;
@@ -295,14 +301,18 @@ private:
void GetGpuErrorDetectedSystemEvent(Kernel::HLERequestContext& ctx);
void GetFriendInvitationStorageChannelEvent(Kernel::HLERequestContext& ctx);
void TryPopFromFriendInvitationStorageChannel(Kernel::HLERequestContext& ctx);
+ void GetNotificationStorageChannelEvent(Kernel::HLERequestContext& ctx);
void GetHealthWarningDisappearedSystemEvent(Kernel::HLERequestContext& ctx);
+ KernelHelpers::ServiceContext service_context;
+
bool launch_popped_application_specific = false;
bool launch_popped_account_preselect = false;
s32 previous_program_index{-1};
- Kernel::KEvent gpu_error_detected_event;
- Kernel::KEvent friend_invitation_storage_channel_event;
- Kernel::KEvent health_warning_disappeared_system_event;
+ Kernel::KEvent* gpu_error_detected_event;
+ Kernel::KEvent* friend_invitation_storage_channel_event;
+ Kernel::KEvent* notification_storage_channel_event;
+ Kernel::KEvent* health_warning_disappeared_system_event;
};
class IHomeMenuFunctions final : public ServiceFramework<IHomeMenuFunctions> {
@@ -314,7 +324,9 @@ private:
void RequestToGetForeground(Kernel::HLERequestContext& ctx);
void GetPopFromGeneralChannelEvent(Kernel::HLERequestContext& ctx);
- Kernel::KEvent pop_from_general_channel_event;
+ KernelHelpers::ServiceContext service_context;
+
+ Kernel::KEvent* pop_from_general_channel_event;
};
class IGlobalStateController final : public ServiceFramework<IGlobalStateController> {
diff --git a/src/core/hle/service/am/applet_ae.h b/src/core/hle/service/am/applet_ae.h
index adb207349..f89f65649 100644
--- a/src/core/hle/service/am/applet_ae.h
+++ b/src/core/hle/service/am/applet_ae.h
@@ -5,7 +5,7 @@
#pragma once
#include <memory>
-#include "core/hle/kernel/hle_ipc.h"
+
#include "core/hle/service/service.h"
namespace Service {
diff --git a/src/core/hle/service/am/applet_oe.h b/src/core/hle/service/am/applet_oe.h
index 6c1aa255a..64b874ead 100644
--- a/src/core/hle/service/am/applet_oe.h
+++ b/src/core/hle/service/am/applet_oe.h
@@ -5,7 +5,7 @@
#pragma once
#include <memory>
-#include "core/hle/kernel/hle_ipc.h"
+
#include "core/hle/service/service.h"
namespace Service {
diff --git a/src/core/hle/service/am/applets/applet_profile_select.cpp b/src/core/hle/service/am/applets/applet_profile_select.cpp
index bdc21778e..a6e891944 100644
--- a/src/core/hle/service/am/applets/applet_profile_select.cpp
+++ b/src/core/hle/service/am/applets/applet_profile_select.cpp
@@ -60,7 +60,7 @@ void ProfileSelect::Execute() {
void ProfileSelect::SelectionComplete(std::optional<Common::UUID> uuid) {
UserSelectionOutput output{};
- if (uuid.has_value() && uuid->uuid != Common::INVALID_UUID) {
+ if (uuid.has_value() && uuid->IsValid()) {
output.result = 0;
output.uuid_selected = uuid->uuid;
} else {
diff --git a/src/core/hle/service/am/applets/applet_web_browser.cpp b/src/core/hle/service/am/applets/applet_web_browser.cpp
index 35f194961..927eeefff 100644
--- a/src/core/hle/service/am/applets/applet_web_browser.cpp
+++ b/src/core/hle/service/am/applets/applet_web_browser.cpp
@@ -24,6 +24,7 @@
#include "core/hle/service/am/applets/applet_web_browser.h"
#include "core/hle/service/filesystem/filesystem.h"
#include "core/hle/service/ns/pl_u.h"
+#include "core/loader/loader.h"
namespace Service::AM::Applets {
@@ -122,6 +123,15 @@ FileSys::VirtualFile GetOfflineRomFS(Core::System& system, u64 title_id,
const auto nca = system.GetContentProvider().GetEntry(title_id, nca_type);
if (nca == nullptr) {
+ if (nca_type == FileSys::ContentRecordType::HtmlDocument) {
+ LOG_WARNING(Service_AM, "Falling back to AppLoader to get the RomFS.");
+ FileSys::VirtualFile romfs;
+ system.GetAppLoader().ReadManualRomFS(romfs);
+ if (romfs != nullptr) {
+ return romfs;
+ }
+ }
+
LOG_ERROR(Service_AM,
"NCA of type={} with title_id={:016X} is not found in the ContentProvider!",
nca_type, title_id);
diff --git a/src/core/hle/service/am/applets/applets.cpp b/src/core/hle/service/am/applets/applets.cpp
index 2b7685d42..7320b1c0f 100644
--- a/src/core/hle/service/am/applets/applets.cpp
+++ b/src/core/hle/service/am/applets/applets.cpp
@@ -12,8 +12,7 @@
#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_readable_event.h"
-#include "core/hle/kernel/k_writable_event.h"
+#include "core/hle/kernel/k_event.h"
#include "core/hle/service/am/am.h"
#include "core/hle/service/am/applet_ae.h"
#include "core/hle/service/am/applet_oe.h"
@@ -29,19 +28,19 @@
namespace Service::AM::Applets {
AppletDataBroker::AppletDataBroker(Core::System& system_, LibraryAppletMode applet_mode_)
- : 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");
+ : system{system_}, applet_mode{applet_mode_}, service_context{system,
+ "ILibraryAppletAccessor"} {
+ state_changed_event = service_context.CreateEvent("ILibraryAppletAccessor:StateChangedEvent");
+ pop_out_data_event = service_context.CreateEvent("ILibraryAppletAccessor:PopDataOutEvent");
+ pop_interactive_out_data_event =
+ service_context.CreateEvent("ILibraryAppletAccessor:PopInteractiveDataOutEvent");
}
-AppletDataBroker::~AppletDataBroker() = default;
+AppletDataBroker::~AppletDataBroker() {
+ service_context.CloseEvent(state_changed_event);
+ service_context.CloseEvent(pop_out_data_event);
+ service_context.CloseEvent(pop_interactive_out_data_event);
+}
AppletDataBroker::RawChannelData AppletDataBroker::PeekDataToAppletForDebug() const {
std::vector<std::vector<u8>> out_normal;
@@ -65,7 +64,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;
}
@@ -84,7 +83,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;
}
@@ -103,7 +102,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) {
@@ -112,11 +111,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() {
- state_changed_event.GetWritableEvent().Signal();
+ state_changed_event->GetWritableEvent().Signal();
switch (applet_mode) {
case LibraryAppletMode::AllForeground:
@@ -141,15 +140,15 @@ void AppletDataBroker::SignalStateChanged() {
}
Kernel::KReadableEvent& AppletDataBroker::GetNormalDataEvent() {
- return pop_out_data_event.GetReadableEvent();
+ return pop_out_data_event->GetReadableEvent();
}
Kernel::KReadableEvent& AppletDataBroker::GetInteractiveDataEvent() {
- return pop_interactive_out_data_event.GetReadableEvent();
+ return pop_interactive_out_data_event->GetReadableEvent();
}
Kernel::KReadableEvent& AppletDataBroker::GetStateChangedEvent() {
- return state_changed_event.GetReadableEvent();
+ 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 5c0b4b459..15eeb4ee1 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/k_event.h"
+#include "core/hle/service/kernel_helpers.h"
union ResultCode;
@@ -105,6 +105,8 @@ private:
Core::System& system;
LibraryAppletMode applet_mode;
+ KernelHelpers::ServiceContext service_context;
+
// Queues are named from applet's perspective
// PopNormalDataToApplet and PushNormalDataFromGame
@@ -119,13 +121,13 @@ private:
// PopInteractiveDataToGame and PushInteractiveDataFromApplet
std::deque<std::shared_ptr<IStorage>> out_interactive_channel;
- Kernel::KEvent state_changed_event;
+ Kernel::KEvent* state_changed_event;
// Signaled on PushNormalDataFromApplet
- Kernel::KEvent pop_out_data_event;
+ Kernel::KEvent* pop_out_data_event;
// Signaled on PushInteractiveDataFromApplet
- Kernel::KEvent pop_interactive_out_data_event;
+ Kernel::KEvent* pop_interactive_out_data_event;
};
class Applet {