diff options
Diffstat (limited to 'src/core/hle/service/am/am.cpp')
-rw-r--r-- | src/core/hle/service/am/am.cpp | 127 |
1 files changed, 71 insertions, 56 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_) |