From 4c1c8801a51335aa4a74e7db0868b861803d0c61 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sat, 6 Jul 2019 13:09:27 -0400 Subject: am: Add RequestExit event to AppletMessageQueue Tested against libnx, signals to games to begin cleanup. --- src/core/hle/service/am/am.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/core/hle/service/am/am.cpp') diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 6c594dcaf..c98fefdeb 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -550,6 +550,10 @@ void AppletMessageQueue::OperationModeChanged() { on_operation_mode_changed.writable->Signal(); } +void AppletMessageQueue::RequestExit() { + PushMessage(AppletMessage::ExitRequested); +} + ICommonStateGetter::ICommonStateGetter(Core::System& system, std::shared_ptr msg_queue) : ServiceFramework("ICommonStateGetter"), system(system), msg_queue(std::move(msg_queue)) { -- cgit v1.2.3 From a7fda849023664212f152adbb0ceed17b246acb0 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sat, 6 Jul 2019 13:41:38 -0400 Subject: am: Implement ISelfController Exit Closes the current application. --- src/core/hle/service/am/am.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/core/hle/service/am/am.cpp') diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index c98fefdeb..7d8649642 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -232,12 +232,12 @@ IDebugFunctions::IDebugFunctions() : ServiceFramework{"IDebugFunctions"} { IDebugFunctions::~IDebugFunctions() = default; -ISelfController::ISelfController(Core::System& system_, - std::shared_ptr nvflinger_) - : ServiceFramework("ISelfController"), nvflinger(std::move(nvflinger_)) { +ISelfController::ISelfController(Core::System& system, + std::shared_ptr nvflinger) + : ServiceFramework("ISelfController"), system(system), nvflinger(std::move(nvflinger)) { // clang-format off static const FunctionInfo functions[] = { - {0, nullptr, "Exit"}, + {0, &ISelfController::Exit, "Exit"}, {1, &ISelfController::LockExit, "LockExit"}, {2, &ISelfController::UnlockExit, "UnlockExit"}, {3, &ISelfController::EnterFatalSection, "EnterFatalSection"}, @@ -298,6 +298,15 @@ ISelfController::ISelfController(Core::System& system_, ISelfController::~ISelfController() = default; +void ISelfController::Exit(Kernel::HLERequestContext& ctx) { + LOG_DEBUG(Service_AM, "called"); + + system.Shutdown(); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(RESULT_SUCCESS); +} + void ISelfController::LockExit(Kernel::HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); -- cgit v1.2.3 From e58e3719d89bd8ce2c919ab154ec93a657807b3a Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sat, 6 Jul 2019 13:42:06 -0400 Subject: am: Implement ISelfController ExitLock commands --- src/core/hle/service/am/am.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/core/hle/service/am/am.cpp') diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 7d8649642..a64e9c430 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -308,14 +308,18 @@ void ISelfController::Exit(Kernel::HLERequestContext& ctx) { } void ISelfController::LockExit(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service_AM, "(STUBBED) called"); + LOG_DEBUG(Service_AM, "called"); + + system.SetExitLock(true); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); } void ISelfController::UnlockExit(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service_AM, "(STUBBED) called"); + LOG_DEBUG(Service_AM, "called"); + + system.SetExitLock(false); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); -- cgit v1.2.3 From 60c2e9e675ce3618d1eedd9a73479c48eb9ba1dc Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sat, 21 Sep 2019 22:46:53 -0400 Subject: qt: Prompt user for confirmation if exit lock is active --- src/core/hle/service/am/am.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/hle/service/am/am.cpp') diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index a64e9c430..c4ddc7c69 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -282,7 +282,7 @@ ISelfController::ISelfController(Core::System& system, RegisterHandlers(functions); - auto& kernel = system_.Kernel(); + auto& kernel = system.Kernel(); launchable_event = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Manual, "ISelfController:LaunchableEvent"); -- cgit v1.2.3