From 5049ca5d8c667ed973ad3ed83d82369243b2a16b Mon Sep 17 00:00:00 2001 From: David <25727384+ogniK5377@users.noreply.github.com> Date: Fri, 24 Aug 2018 08:31:45 +1000 Subject: [PATCH] Added GetBootMode (#1107) * Added GetBootMode Used by homebrew * Added enum for GetBootMode --- src/core/hle/service/am/am.cpp | 12 +++++++++++- src/core/hle/service/am/am.h | 1 + src/core/hle/service/pm/pm.cpp | 13 ++++++++++++- src/core/hle/service/pm/pm.h | 2 +- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 78d551a8a9..7e3cf6d583 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -18,6 +18,7 @@ #include "core/hle/service/apm/apm.h" #include "core/hle/service/filesystem/filesystem.h" #include "core/hle/service/nvflinger/nvflinger.h" +#include "core/hle/service/pm/pm.h" #include "core/hle/service/set/set.h" #include "core/settings.h" @@ -309,7 +310,7 @@ ICommonStateGetter::ICommonStateGetter() : ServiceFramework("ICommonStateGetter" {5, &ICommonStateGetter::GetOperationMode, "GetOperationMode"}, {6, &ICommonStateGetter::GetPerformanceMode, "GetPerformanceMode"}, {7, nullptr, "GetCradleStatus"}, - {8, nullptr, "GetBootMode"}, + {8, &ICommonStateGetter::GetBootMode, "GetBootMode"}, {9, &ICommonStateGetter::GetCurrentFocusState, "GetCurrentFocusState"}, {10, nullptr, "RequestToAcquireSleepLock"}, {11, nullptr, "ReleaseSleepLock"}, @@ -334,6 +335,15 @@ ICommonStateGetter::ICommonStateGetter() : ServiceFramework("ICommonStateGetter" event = Kernel::Event::Create(Kernel::ResetType::OneShot, "ICommonStateGetter:Event"); } +void ICommonStateGetter::GetBootMode(Kernel::HLERequestContext& ctx) { + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(RESULT_SUCCESS); + + rb.Push(static_cast(Service::PM::SystemBootMode::Normal)); // Normal boot mode + + LOG_DEBUG(Service_AM, "called"); +} + void ICommonStateGetter::GetEventHandle(Kernel::HLERequestContext& ctx) { event->Signal(); diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index b763aff6f9..9e8bb4e439 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -116,6 +116,7 @@ private: void GetDefaultDisplayResolutionChangeEvent(Kernel::HLERequestContext& ctx); void GetOperationMode(Kernel::HLERequestContext& ctx); void GetPerformanceMode(Kernel::HLERequestContext& ctx); + void GetBootMode(Kernel::HLERequestContext& ctx); Kernel::SharedPtr event; }; diff --git a/src/core/hle/service/pm/pm.cpp b/src/core/hle/service/pm/pm.cpp index e20a256899..6ec35ca606 100644 --- a/src/core/hle/service/pm/pm.cpp +++ b/src/core/hle/service/pm/pm.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "core/hle/ipc_helpers.h" +#include "core/hle/service/pm/pm.h" #include "core/hle/service/service.h" namespace Service::PM { @@ -10,11 +12,20 @@ class BootMode final : public ServiceFramework { public: explicit BootMode() : ServiceFramework{"pm:bm"} { static const FunctionInfo functions[] = { - {0, nullptr, "GetBootMode"}, + {0, &BootMode::GetBootMode, "GetBootMode"}, {1, nullptr, "SetMaintenanceBoot"}, }; RegisterHandlers(functions); } + +private: + void GetBootMode(Kernel::HLERequestContext& ctx) { + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(RESULT_SUCCESS); + rb.Push(static_cast(SystemBootMode::Normal)); // Normal boot mode + + LOG_DEBUG(Service_PM, "called"); + } }; class DebugMonitor final : public ServiceFramework { diff --git a/src/core/hle/service/pm/pm.h b/src/core/hle/service/pm/pm.h index 9fc19fed62..370f2ed722 100644 --- a/src/core/hle/service/pm/pm.h +++ b/src/core/hle/service/pm/pm.h @@ -9,7 +9,7 @@ class ServiceManager; } namespace Service::PM { - +enum class SystemBootMode : u32 { Normal = 0, Maintenance = 1 }; /// Registers all PM services with the specified service manager. void InstallInterfaces(SM::ServiceManager& service_manager);