summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar David2019-09-23 00:37:12 +1000
committerGravatar GitHub2019-09-23 00:37:12 +1000
commitaaec1562f8631303d1a5abb6c75f2422d6d7cf71 (patch)
tree283ac1330252c06b3a1741730ce49f4182330150 /src/core
parentMerge pull request #2889 from FearlessTobi/adwsawdawd (diff)
parentmain: Use const on all variable initializations (diff)
downloadyuzu-aaec1562f8631303d1a5abb6c75f2422d6d7cf71.tar.gz
yuzu-aaec1562f8631303d1a5abb6c75f2422d6d7cf71.tar.xz
yuzu-aaec1562f8631303d1a5abb6c75f2422d6d7cf71.zip
Merge pull request #2683 from DarkLordZach/lock-exit
am: Implement exit locking and self exit commands
Diffstat (limited to 'src/core')
-rw-r--r--src/core/core.cpp11
-rw-r--r--src/core/core.h4
-rw-r--r--src/core/hle/service/am/am.cpp31
-rw-r--r--src/core/hle/service/am/am.h5
-rw-r--r--src/core/hle/service/am/applet_ae.h2
-rw-r--r--src/core/hle/service/am/applet_oe.h2
6 files changed, 48 insertions, 7 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 76bb2bae9..92ba42fb9 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -163,6 +163,7 @@ struct System::Impl {
163 gpu_core = VideoCore::CreateGPU(system); 163 gpu_core = VideoCore::CreateGPU(system);
164 164
165 is_powered_on = true; 165 is_powered_on = true;
166 exit_lock = false;
166 167
167 LOG_DEBUG(Core, "Initialized OK"); 168 LOG_DEBUG(Core, "Initialized OK");
168 169
@@ -249,6 +250,7 @@ struct System::Impl {
249 perf_stats->GetMeanFrametime()); 250 perf_stats->GetMeanFrametime());
250 251
251 is_powered_on = false; 252 is_powered_on = false;
253 exit_lock = false;
252 254
253 // Shutdown emulation session 255 // Shutdown emulation session
254 renderer.reset(); 256 renderer.reset();
@@ -333,6 +335,7 @@ struct System::Impl {
333 std::unique_ptr<Core::Hardware::InterruptManager> interrupt_manager; 335 std::unique_ptr<Core::Hardware::InterruptManager> interrupt_manager;
334 CpuCoreManager cpu_core_manager; 336 CpuCoreManager cpu_core_manager;
335 bool is_powered_on = false; 337 bool is_powered_on = false;
338 bool exit_lock = false;
336 339
337 std::unique_ptr<Memory::CheatEngine> cheat_engine; 340 std::unique_ptr<Memory::CheatEngine> cheat_engine;
338 std::unique_ptr<Tools::Freezer> memory_freezer; 341 std::unique_ptr<Tools::Freezer> memory_freezer;
@@ -629,6 +632,14 @@ const Service::APM::Controller& System::GetAPMController() const {
629 return impl->apm_controller; 632 return impl->apm_controller;
630} 633}
631 634
635void System::SetExitLock(bool locked) {
636 impl->exit_lock = locked;
637}
638
639bool System::GetExitLock() const {
640 return impl->exit_lock;
641}
642
632System::ResultStatus System::Init(Frontend::EmuWindow& emu_window) { 643System::ResultStatus System::Init(Frontend::EmuWindow& emu_window) {
633 return impl->Init(*this, emu_window); 644 return impl->Init(*this, emu_window);
634} 645}
diff --git a/src/core/core.h b/src/core/core.h
index d2a3c82d8..ff10ebe12 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -326,6 +326,10 @@ public:
326 326
327 const Service::APM::Controller& GetAPMController() const; 327 const Service::APM::Controller& GetAPMController() const;
328 328
329 void SetExitLock(bool locked);
330
331 bool GetExitLock() const;
332
329private: 333private:
330 System(); 334 System();
331 335
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index 3366fd8ce..797c9a06f 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"} {
232 232
233IDebugFunctions::~IDebugFunctions() = default; 233IDebugFunctions::~IDebugFunctions() = default;
234 234
235ISelfController::ISelfController(Core::System& system_, 235ISelfController::ISelfController(Core::System& system,
236 std::shared_ptr<NVFlinger::NVFlinger> nvflinger_) 236 std::shared_ptr<NVFlinger::NVFlinger> nvflinger)
237 : ServiceFramework("ISelfController"), nvflinger(std::move(nvflinger_)) { 237 : ServiceFramework("ISelfController"), system(system), nvflinger(std::move(nvflinger)) {
238 // clang-format off 238 // clang-format off
239 static const FunctionInfo functions[] = { 239 static const FunctionInfo functions[] = {
240 {0, nullptr, "Exit"}, 240 {0, &ISelfController::Exit, "Exit"},
241 {1, &ISelfController::LockExit, "LockExit"}, 241 {1, &ISelfController::LockExit, "LockExit"},
242 {2, &ISelfController::UnlockExit, "UnlockExit"}, 242 {2, &ISelfController::UnlockExit, "UnlockExit"},
243 {3, &ISelfController::EnterFatalSection, "EnterFatalSection"}, 243 {3, &ISelfController::EnterFatalSection, "EnterFatalSection"},
@@ -282,7 +282,7 @@ ISelfController::ISelfController(Core::System& system_,
282 282
283 RegisterHandlers(functions); 283 RegisterHandlers(functions);
284 284
285 auto& kernel = system_.Kernel(); 285 auto& kernel = system.Kernel();
286 launchable_event = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Manual, 286 launchable_event = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Manual,
287 "ISelfController:LaunchableEvent"); 287 "ISelfController:LaunchableEvent");
288 288
@@ -298,15 +298,28 @@ ISelfController::ISelfController(Core::System& system_,
298 298
299ISelfController::~ISelfController() = default; 299ISelfController::~ISelfController() = default;
300 300
301void ISelfController::Exit(Kernel::HLERequestContext& ctx) {
302 LOG_DEBUG(Service_AM, "called");
303
304 system.Shutdown();
305
306 IPC::ResponseBuilder rb{ctx, 2};
307 rb.Push(RESULT_SUCCESS);
308}
309
301void ISelfController::LockExit(Kernel::HLERequestContext& ctx) { 310void ISelfController::LockExit(Kernel::HLERequestContext& ctx) {
302 LOG_WARNING(Service_AM, "(STUBBED) called"); 311 LOG_DEBUG(Service_AM, "called");
312
313 system.SetExitLock(true);
303 314
304 IPC::ResponseBuilder rb{ctx, 2}; 315 IPC::ResponseBuilder rb{ctx, 2};
305 rb.Push(RESULT_SUCCESS); 316 rb.Push(RESULT_SUCCESS);
306} 317}
307 318
308void ISelfController::UnlockExit(Kernel::HLERequestContext& ctx) { 319void ISelfController::UnlockExit(Kernel::HLERequestContext& ctx) {
309 LOG_WARNING(Service_AM, "(STUBBED) called"); 320 LOG_DEBUG(Service_AM, "called");
321
322 system.SetExitLock(false);
310 323
311 IPC::ResponseBuilder rb{ctx, 2}; 324 IPC::ResponseBuilder rb{ctx, 2};
312 rb.Push(RESULT_SUCCESS); 325 rb.Push(RESULT_SUCCESS);
@@ -550,6 +563,10 @@ void AppletMessageQueue::OperationModeChanged() {
550 on_operation_mode_changed.writable->Signal(); 563 on_operation_mode_changed.writable->Signal();
551} 564}
552 565
566void AppletMessageQueue::RequestExit() {
567 PushMessage(AppletMessage::ExitRequested);
568}
569
553ICommonStateGetter::ICommonStateGetter(Core::System& system, 570ICommonStateGetter::ICommonStateGetter(Core::System& system,
554 std::shared_ptr<AppletMessageQueue> msg_queue) 571 std::shared_ptr<AppletMessageQueue> msg_queue)
555 : ServiceFramework("ICommonStateGetter"), system(system), msg_queue(std::move(msg_queue)) { 572 : ServiceFramework("ICommonStateGetter"), system(system), msg_queue(std::move(msg_queue)) {
diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h
index 28f870302..a3baeb673 100644
--- a/src/core/hle/service/am/am.h
+++ b/src/core/hle/service/am/am.h
@@ -45,6 +45,7 @@ class AppletMessageQueue {
45public: 45public:
46 enum class AppletMessage : u32 { 46 enum class AppletMessage : u32 {
47 NoMessage = 0, 47 NoMessage = 0,
48 ExitRequested = 4,
48 FocusStateChanged = 15, 49 FocusStateChanged = 15,
49 OperationModeChanged = 30, 50 OperationModeChanged = 30,
50 PerformanceModeChanged = 31, 51 PerformanceModeChanged = 31,
@@ -59,6 +60,7 @@ public:
59 AppletMessage PopMessage(); 60 AppletMessage PopMessage();
60 std::size_t GetMessageCount() const; 61 std::size_t GetMessageCount() const;
61 void OperationModeChanged(); 62 void OperationModeChanged();
63 void RequestExit();
62 64
63private: 65private:
64 std::queue<AppletMessage> messages; 66 std::queue<AppletMessage> messages;
@@ -123,6 +125,7 @@ public:
123 ~ISelfController() override; 125 ~ISelfController() override;
124 126
125private: 127private:
128 void Exit(Kernel::HLERequestContext& ctx);
126 void LockExit(Kernel::HLERequestContext& ctx); 129 void LockExit(Kernel::HLERequestContext& ctx);
127 void UnlockExit(Kernel::HLERequestContext& ctx); 130 void UnlockExit(Kernel::HLERequestContext& ctx);
128 void EnterFatalSection(Kernel::HLERequestContext& ctx); 131 void EnterFatalSection(Kernel::HLERequestContext& ctx);
@@ -151,6 +154,8 @@ private:
151 u32 idle_time_detection_extension = 0; 154 u32 idle_time_detection_extension = 0;
152 u64 num_fatal_sections_entered = 0; 155 u64 num_fatal_sections_entered = 0;
153 bool is_auto_sleep_disabled = false; 156 bool is_auto_sleep_disabled = false;
157
158 Core::System& system;
154}; 159};
155 160
156class ICommonStateGetter final : public ServiceFramework<ICommonStateGetter> { 161class ICommonStateGetter final : public ServiceFramework<ICommonStateGetter> {
diff --git a/src/core/hle/service/am/applet_ae.h b/src/core/hle/service/am/applet_ae.h
index 0e0d10858..2e3e45915 100644
--- a/src/core/hle/service/am/applet_ae.h
+++ b/src/core/hle/service/am/applet_ae.h
@@ -19,6 +19,8 @@ class NVFlinger;
19 19
20namespace AM { 20namespace AM {
21 21
22class AppletMessageQueue;
23
22class AppletAE final : public ServiceFramework<AppletAE> { 24class AppletAE final : public ServiceFramework<AppletAE> {
23public: 25public:
24 explicit AppletAE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger, 26 explicit AppletAE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger,
diff --git a/src/core/hle/service/am/applet_oe.h b/src/core/hle/service/am/applet_oe.h
index 99a65e7b5..758da792d 100644
--- a/src/core/hle/service/am/applet_oe.h
+++ b/src/core/hle/service/am/applet_oe.h
@@ -19,6 +19,8 @@ class NVFlinger;
19 19
20namespace AM { 20namespace AM {
21 21
22class AppletMessageQueue;
23
22class AppletOE final : public ServiceFramework<AppletOE> { 24class AppletOE final : public ServiceFramework<AppletOE> {
23public: 25public:
24 explicit AppletOE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger, 26 explicit AppletOE(std::shared_ptr<NVFlinger::NVFlinger> nvflinger,