diff --git a/libraries/libstratosphere/include/stratosphere/pm.hpp b/libraries/libstratosphere/include/stratosphere/pm.hpp index 801993fc1..5b252aefb 100644 --- a/libraries/libstratosphere/include/stratosphere/pm.hpp +++ b/libraries/libstratosphere/include/stratosphere/pm.hpp @@ -16,8 +16,12 @@ #pragma once -#include "pm/pm_types.hpp" -#include "pm/pm_boot_mode_api.hpp" -#include "pm/pm_info_api.hpp" -#include "pm/pm_shell_api.hpp" -#include "pm/pm_dmnt_api.hpp" \ No newline at end of file +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/libraries/libstratosphere/include/stratosphere/pm/impl/pm_boot_mode_interface.hpp b/libraries/libstratosphere/include/stratosphere/pm/impl/pm_boot_mode_interface.hpp new file mode 100644 index 000000000..9f37bacc5 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/pm/impl/pm_boot_mode_interface.hpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once +#include +#include +#include + +namespace ams::pm::impl { + + #define AMS_PM_I_BOOT_MODE_INTERFACE_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, void, GetBootMode, (sf::Out out)) \ + AMS_SF_METHOD_INFO(C, H, 1, void, SetMaintenanceBoot, ()) + + AMS_SF_DEFINE_INTERFACE(IBootModeInterface, AMS_PM_I_BOOT_MODE_INTERFACE_INTERFACE_INFO) + +} diff --git a/libraries/libstratosphere/include/stratosphere/pm/impl/pm_debug_monitor_interface.hpp b/libraries/libstratosphere/include/stratosphere/pm/impl/pm_debug_monitor_interface.hpp new file mode 100644 index 000000000..1e3bfa6d6 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/pm/impl/pm_debug_monitor_interface.hpp @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once +#include +#include +#include + +namespace ams::pm::impl { + + #define AMS_PM_I_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, GetExceptionProcessIdList, (sf::Out out_count, const sf::OutArray &out_process_ids)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, StartProcess, (os::ProcessId process_id)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, GetProcessId, (sf::Out out, ncm::ProgramId program_id)) \ + AMS_SF_METHOD_INFO(C, H, 3, Result, HookToCreateProcess, (sf::OutCopyHandle out_hook, ncm::ProgramId program_id)) \ + AMS_SF_METHOD_INFO(C, H, 4, Result, GetApplicationProcessId, (sf::Out out)) \ + AMS_SF_METHOD_INFO(C, H, 5, Result, HookToCreateApplicationProcess, (sf::OutCopyHandle out_hook)) \ + AMS_SF_METHOD_INFO(C, H, 6, Result, ClearHook, (u32 which), hos::Version_6_0_0) \ + AMS_SF_METHOD_INFO(C, H, 65000, Result, AtmosphereGetProcessInfo, (sf::OutCopyHandle out_process_handle, sf::Out out_loc, sf::Out out_status, os::ProcessId process_id)) \ + AMS_SF_METHOD_INFO(C, H, 65001, Result, AtmosphereGetCurrentLimitInfo, (sf::Out out_cur_val, sf::Out out_lim_val, u32 group, u32 resource)) + + AMS_SF_DEFINE_INTERFACE(IDebugMonitorInterface, AMS_PM_I_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO) + + #define AMS_PM_I_DEPRECATED_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, GetModuleIdList, (sf::Out out_count, const sf::OutBuffer &out_buf, u64 unused)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, GetExceptionProcessIdList, (sf::Out out_count, const sf::OutArray &out_process_ids)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, StartProcess, (os::ProcessId process_id)) \ + AMS_SF_METHOD_INFO(C, H, 3, Result, GetProcessId, (sf::Out out, ncm::ProgramId program_id)) \ + AMS_SF_METHOD_INFO(C, H, 4, Result, HookToCreateProcess, (sf::OutCopyHandle out_hook, ncm::ProgramId program_id)) \ + AMS_SF_METHOD_INFO(C, H, 5, Result, GetApplicationProcessId, (sf::Out out)) \ + AMS_SF_METHOD_INFO(C, H, 6, Result, HookToCreateApplicationProcess, (sf::OutCopyHandle out_hook)) \ + AMS_SF_METHOD_INFO(C, H, 65000, Result, AtmosphereGetProcessInfo, (sf::OutCopyHandle out_process_handle, sf::Out out_loc, sf::Out out_status, os::ProcessId process_id)) \ + AMS_SF_METHOD_INFO(C, H, 65001, Result, AtmosphereGetCurrentLimitInfo, (sf::Out out_cur_val, sf::Out out_lim_val, u32 group, u32 resource)) + + AMS_SF_DEFINE_INTERFACE(IDeprecatedDebugMonitorInterface, AMS_PM_I_DEPRECATED_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO) + +} diff --git a/libraries/libstratosphere/include/stratosphere/pm/impl/pm_information_interface.hpp b/libraries/libstratosphere/include/stratosphere/pm/impl/pm_information_interface.hpp new file mode 100644 index 000000000..c09b3b208 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/pm/impl/pm_information_interface.hpp @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once +#include +#include +#include + +namespace ams::pm::impl { + + #define AMS_PM_I_INFORMATION_INTERFACE_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, GetProgramId, (sf::Out out, os::ProcessId process_id)) \ + AMS_SF_METHOD_INFO(C, H, 65000, Result, AtmosphereGetProcessId, (sf::Out out, ncm::ProgramId program_id)) \ + AMS_SF_METHOD_INFO(C, H, 65001, Result, AtmosphereHasLaunchedProgram, (sf::Out out, ncm::ProgramId program_id)) \ + AMS_SF_METHOD_INFO(C, H, 65002, Result, AtmosphereGetProcessInfo, (sf::Out out_loc, sf::Out out_status, os::ProcessId process_id)) + + AMS_SF_DEFINE_INTERFACE(IInformationInterface, AMS_PM_I_INFORMATION_INTERFACE_INTERFACE_INFO) + +} diff --git a/libraries/libstratosphere/include/stratosphere/pm/impl/pm_shell_interface.hpp b/libraries/libstratosphere/include/stratosphere/pm/impl/pm_shell_interface.hpp new file mode 100644 index 000000000..1343b7919 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/pm/impl/pm_shell_interface.hpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once +#include +#include +#include + +namespace ams::pm::impl { + + #define AMS_PM_I_SHELL_INTERFACE_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, LaunchProgram, (sf::Out out_process_id, const ncm::ProgramLocation &loc, u32 flags)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, TerminateProcess, (os::ProcessId process_id)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, TerminateProgram, (ncm::ProgramId program_id)) \ + AMS_SF_METHOD_INFO(C, H, 3, void, GetProcessEventHandle, (sf::OutCopyHandle out)) \ + AMS_SF_METHOD_INFO(C, H, 4, void, GetProcessEventInfo, (sf::Out out)) \ + AMS_SF_METHOD_INFO(C, H, 5, void, NotifyBootFinished, ()) \ + AMS_SF_METHOD_INFO(C, H, 6, Result, GetApplicationProcessIdForShell, (sf::Out out)) \ + AMS_SF_METHOD_INFO(C, H, 7, Result, BoostSystemMemoryResourceLimit, (u64 boost_size)) \ + AMS_SF_METHOD_INFO(C, H, 8, Result, BoostApplicationThreadResourceLimit, (), hos::Version_7_0_0) \ + AMS_SF_METHOD_INFO(C, H, 9, void, GetBootFinishedEventHandle, (sf::OutCopyHandle out), hos::Version_8_0_0) + + AMS_SF_DEFINE_INTERFACE(IShellInterface, AMS_PM_I_SHELL_INTERFACE_INTERFACE_INFO) + + #define AMS_PM_I_DEPRECATED_SHELL_INTERFACE_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, LaunchProgram, (sf::Out out_process_id, const ncm::ProgramLocation &loc, u32 flags)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, TerminateProcess, (os::ProcessId process_id)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, TerminateProgram, (ncm::ProgramId program_id)) \ + AMS_SF_METHOD_INFO(C, H, 3, void, GetProcessEventHandle, (sf::OutCopyHandle out)) \ + AMS_SF_METHOD_INFO(C, H, 4, void, GetProcessEventInfo, (sf::Out out)) \ + AMS_SF_METHOD_INFO(C, H, 5, Result, CleanupProcess, (os::ProcessId process_id)) \ + AMS_SF_METHOD_INFO(C, H, 6, Result, ClearExceptionOccurred, (os::ProcessId process_id)) \ + AMS_SF_METHOD_INFO(C, H, 7, void, NotifyBootFinished, ()) \ + AMS_SF_METHOD_INFO(C, H, 8, Result, GetApplicationProcessIdForShell, (sf::Out out)) \ + AMS_SF_METHOD_INFO(C, H, 9, Result, BoostSystemMemoryResourceLimit, (u64 boost_size), hos::Version_4_0_0) + + AMS_SF_DEFINE_INTERFACE(IDeprecatedShellInterface, AMS_PM_I_DEPRECATED_SHELL_INTERFACE_INTERFACE_INFO) + +} diff --git a/stratosphere/pgl/source/pgl_main.cpp b/stratosphere/pgl/source/pgl_main.cpp index cc5d89650..8532d6cc0 100644 --- a/stratosphere/pgl/source/pgl_main.cpp +++ b/stratosphere/pgl/source/pgl_main.cpp @@ -66,12 +66,8 @@ namespace ams::pgl { constinit pgl::srv::ShellInterface g_shell_interface; - ALWAYS_INLINE std::shared_ptr GetSharedPointerToShellInterface() { - return ams::sf::ServiceObjectTraits::SharedPointerHelper::GetEmptyDeleteSharedPointer(std::addressof(g_shell_interface)); - } - void RegisterServiceSession() { - R_ABORT_UNLESS(g_server_manager.RegisterServer(ShellServiceName, ShellMaxSessions, GetSharedPointerToShellInterface())); + R_ABORT_UNLESS((g_server_manager.RegisterServer(ShellServiceName, ShellMaxSessions, ams::sf::GetSharedPointerTo(g_shell_interface)))); } void LoopProcess() { diff --git a/stratosphere/pm/source/pm_boot_mode_service.cpp b/stratosphere/pm/source/pm_boot_mode_service.cpp index e185ddf0a..290f05f27 100644 --- a/stratosphere/pm/source/pm_boot_mode_service.cpp +++ b/stratosphere/pm/source/pm_boot_mode_service.cpp @@ -16,7 +16,7 @@ #include #include "pm_boot_mode_service.hpp" -namespace ams::pm::bm { +namespace ams::pm { namespace { @@ -26,12 +26,16 @@ namespace ams::pm::bm { } /* Override of weakly linked boot_mode_api functions. */ - BootMode GetBootMode() { - return g_boot_mode; - } + namespace bm { + + BootMode GetBootMode() { + return g_boot_mode; + } + + void SetMaintenanceBoot() { + g_boot_mode = BootMode::Maintenance; + } - void SetMaintenanceBoot() { - g_boot_mode = BootMode::Maintenance; } /* Service command implementations. */ diff --git a/stratosphere/pm/source/pm_boot_mode_service.hpp b/stratosphere/pm/source/pm_boot_mode_service.hpp index a15f66d15..c7b6fc0b7 100644 --- a/stratosphere/pm/source/pm_boot_mode_service.hpp +++ b/stratosphere/pm/source/pm_boot_mode_service.hpp @@ -16,23 +16,13 @@ #pragma once #include -namespace ams::pm::bm { +namespace ams::pm { - class BootModeService final : public sf::IServiceObject { - private: - enum class CommandId { - GetBootMode = 0, - SetMaintenanceBoot = 1, - }; - private: - /* Actual command implementations. */ + class BootModeService final { + public: void GetBootMode(sf::Out out); void SetMaintenanceBoot(); - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(GetBootMode), - MAKE_SERVICE_COMMAND_META(SetMaintenanceBoot), - }; }; + static_assert(pm::impl::IsIBootModeInterface); } diff --git a/stratosphere/pm/source/pm_debug_monitor_service.cpp b/stratosphere/pm/source/pm_debug_monitor_service.cpp index a42156a55..2fd98f893 100644 --- a/stratosphere/pm/source/pm_debug_monitor_service.cpp +++ b/stratosphere/pm/source/pm_debug_monitor_service.cpp @@ -17,49 +17,49 @@ #include "pm_debug_monitor_service.hpp" #include "impl/pm_process_manager.hpp" -namespace ams::pm::dmnt { +namespace ams::pm { /* Actual command implementations. */ - Result DebugMonitorServiceBase::GetModuleIdList(sf::Out out_count, const sf::OutBuffer &out_buf, u64 unused) { + Result DebugMonitorService::GetModuleIdList(sf::Out out_count, const sf::OutBuffer &out_buf, u64 unused) { R_UNLESS(out_buf.GetSize() <= std::numeric_limits::max(), pm::ResultInvalidSize()); return impl::GetModuleIdList(out_count.GetPointer(), out_buf.GetPointer(), out_buf.GetSize(), unused); } - Result DebugMonitorServiceBase::GetExceptionProcessIdList(sf::Out out_count, const sf::OutArray &out_process_ids) { + Result DebugMonitorService::GetExceptionProcessIdList(sf::Out out_count, const sf::OutArray &out_process_ids) { R_UNLESS(out_process_ids.GetSize() <= std::numeric_limits::max(), pm::ResultInvalidSize()); return impl::GetExceptionProcessIdList(out_count.GetPointer(), out_process_ids.GetPointer(), out_process_ids.GetSize()); } - Result DebugMonitorServiceBase::StartProcess(os::ProcessId process_id) { + Result DebugMonitorService::StartProcess(os::ProcessId process_id) { return impl::StartProcess(process_id); } - Result DebugMonitorServiceBase::GetProcessId(sf::Out out, ncm::ProgramId program_id) { + Result DebugMonitorService::GetProcessId(sf::Out out, ncm::ProgramId program_id) { return impl::GetProcessId(out.GetPointer(), program_id); } - Result DebugMonitorServiceBase::HookToCreateProcess(sf::OutCopyHandle out_hook, ncm::ProgramId program_id) { + Result DebugMonitorService::HookToCreateProcess(sf::OutCopyHandle out_hook, ncm::ProgramId program_id) { return impl::HookToCreateProcess(out_hook.GetHandlePointer(), program_id); } - Result DebugMonitorServiceBase::GetApplicationProcessId(sf::Out out) { + Result DebugMonitorService::GetApplicationProcessId(sf::Out out) { return impl::GetApplicationProcessId(out.GetPointer()); } - Result DebugMonitorServiceBase::HookToCreateApplicationProcess(sf::OutCopyHandle out_hook) { + Result DebugMonitorService::HookToCreateApplicationProcess(sf::OutCopyHandle out_hook) { return impl::HookToCreateApplicationProcess(out_hook.GetHandlePointer()); } - Result DebugMonitorServiceBase::ClearHook(u32 which) { + Result DebugMonitorService::ClearHook(u32 which) { return impl::ClearHook(which); } /* Atmosphere extension commands. */ - Result DebugMonitorServiceBase::AtmosphereGetProcessInfo(sf::OutCopyHandle out_process_handle, sf::Out out_loc, sf::Out out_status, os::ProcessId process_id) { + Result DebugMonitorService::AtmosphereGetProcessInfo(sf::OutCopyHandle out_process_handle, sf::Out out_loc, sf::Out out_status, os::ProcessId process_id) { return impl::AtmosphereGetProcessInfo(out_process_handle.GetHandlePointer(), out_loc.GetPointer(), out_status.GetPointer(), process_id); } - Result DebugMonitorServiceBase::AtmosphereGetCurrentLimitInfo(sf::Out out_cur_val, sf::Out out_lim_val, u32 group, u32 resource) { + Result DebugMonitorService::AtmosphereGetCurrentLimitInfo(sf::Out out_cur_val, sf::Out out_lim_val, u32 group, u32 resource) { return impl::AtmosphereGetCurrentLimitInfo(out_cur_val.GetPointer(), out_lim_val.GetPointer(), group, resource); } diff --git a/stratosphere/pm/source/pm_debug_monitor_service.hpp b/stratosphere/pm/source/pm_debug_monitor_service.hpp index 396d86e20..634e61104 100644 --- a/stratosphere/pm/source/pm_debug_monitor_service.hpp +++ b/stratosphere/pm/source/pm_debug_monitor_service.hpp @@ -16,90 +16,24 @@ #pragma once #include -namespace ams::pm::dmnt { +namespace ams::pm { - class DebugMonitorServiceBase : public sf::IServiceObject { - protected: + class DebugMonitorService final { + public: /* Actual command implementations. */ - virtual Result GetModuleIdList(sf::Out out_count, const sf::OutBuffer &out_buf, u64 unused); - virtual Result GetExceptionProcessIdList(sf::Out out_count, const sf::OutArray &out_process_ids); - virtual Result StartProcess(os::ProcessId process_id); - virtual Result GetProcessId(sf::Out out, ncm::ProgramId program_id); - virtual Result HookToCreateProcess(sf::OutCopyHandle out_hook, ncm::ProgramId program_id); - virtual Result GetApplicationProcessId(sf::Out out); - virtual Result HookToCreateApplicationProcess(sf::OutCopyHandle out_hook); - virtual Result ClearHook(u32 which); + Result GetModuleIdList(sf::Out out_count, const sf::OutBuffer &out_buf, u64 unused); + Result GetExceptionProcessIdList(sf::Out out_count, const sf::OutArray &out_process_ids); + Result StartProcess(os::ProcessId process_id); + Result GetProcessId(sf::Out out, ncm::ProgramId program_id); + Result HookToCreateProcess(sf::OutCopyHandle out_hook, ncm::ProgramId program_id); + Result GetApplicationProcessId(sf::Out out); + Result HookToCreateApplicationProcess(sf::OutCopyHandle out_hook); + Result ClearHook(u32 which); /* Atmosphere extension commands. */ - virtual Result AtmosphereGetProcessInfo(sf::OutCopyHandle out_process_handle, sf::Out out_loc, sf::Out out_status, os::ProcessId process_id); - virtual Result AtmosphereGetCurrentLimitInfo(sf::Out out_cur_val, sf::Out out_lim_val, u32 group, u32 resource); - }; - - /* This represents modern DebugMonitorService (5.0.0+). */ - class DebugMonitorService final : public DebugMonitorServiceBase { - private: - enum class CommandId { - GetExceptionProcessIdList = 0, - StartProcess = 1, - GetProcessId = 2, - HookToCreateProcess = 3, - GetApplicationProcessId = 4, - HookToCreateApplicationProcess = 5, - - ClearHook = 6, - - AtmosphereGetProcessInfo = 65000, - AtmosphereGetCurrentLimitInfo = 65001, - }; - public: - DEFINE_SERVICE_DISPATCH_TABLE { - /* 5.0.0-* */ - MAKE_SERVICE_COMMAND_META(GetExceptionProcessIdList), - MAKE_SERVICE_COMMAND_META(StartProcess), - MAKE_SERVICE_COMMAND_META(GetProcessId), - MAKE_SERVICE_COMMAND_META(HookToCreateProcess), - MAKE_SERVICE_COMMAND_META(GetApplicationProcessId), - MAKE_SERVICE_COMMAND_META(HookToCreateApplicationProcess), - - /* 6.0.0-* */ - MAKE_SERVICE_COMMAND_META(ClearHook, hos::Version_6_0_0), - - /* Atmosphere extensions. */ - MAKE_SERVICE_COMMAND_META(AtmosphereGetProcessInfo), - MAKE_SERVICE_COMMAND_META(AtmosphereGetCurrentLimitInfo), - }; - }; - - /* This represents deprecated DebugMonitorService (1.0.0-4.1.0). */ - class DebugMonitorServiceDeprecated final : public DebugMonitorServiceBase { - private: - enum class CommandId { - GetModuleIdList = 0, - GetExceptionProcessIdList = 1, - StartProcess = 2, - GetProcessId = 3, - HookToCreateProcess = 4, - GetApplicationProcessId = 5, - HookToCreateApplicationProcess = 6, - - AtmosphereGetProcessInfo = 65000, - AtmosphereGetCurrentLimitInfo = 65001, - }; - public: - DEFINE_SERVICE_DISPATCH_TABLE { - /* 1.0.0-4.1.0 */ - MAKE_SERVICE_COMMAND_META(GetModuleIdList), - MAKE_SERVICE_COMMAND_META(GetExceptionProcessIdList), - MAKE_SERVICE_COMMAND_META(StartProcess), - MAKE_SERVICE_COMMAND_META(GetProcessId), - MAKE_SERVICE_COMMAND_META(HookToCreateProcess), - MAKE_SERVICE_COMMAND_META(GetApplicationProcessId), - MAKE_SERVICE_COMMAND_META(HookToCreateApplicationProcess), - - /* Atmosphere extensions. */ - MAKE_SERVICE_COMMAND_META(AtmosphereGetProcessInfo), - MAKE_SERVICE_COMMAND_META(AtmosphereGetCurrentLimitInfo), - }; + Result AtmosphereGetProcessInfo(sf::OutCopyHandle out_process_handle, sf::Out out_loc, sf::Out out_status, os::ProcessId process_id); + Result AtmosphereGetCurrentLimitInfo(sf::Out out_cur_val, sf::Out out_lim_val, u32 group, u32 resource); }; + static_assert(pm::impl::IsIDebugMonitorInterface); } diff --git a/stratosphere/pm/source/pm_info_service.cpp b/stratosphere/pm/source/pm_info_service.cpp index d6e34e30b..5ec0f23a4 100644 --- a/stratosphere/pm/source/pm_info_service.cpp +++ b/stratosphere/pm/source/pm_info_service.cpp @@ -17,11 +17,15 @@ #include "pm_info_service.hpp" #include "impl/pm_process_manager.hpp" -namespace ams::pm::info { +namespace ams::pm { /* Overrides for libstratosphere pm::info commands. */ - Result HasLaunchedProgram(bool *out, ncm::ProgramId program_id) { - return ldr::pm::HasLaunchedProgram(out, program_id); + namespace info { + + Result HasLaunchedProgram(bool *out, ncm::ProgramId program_id) { + return ldr::pm::HasLaunchedProgram(out, program_id); + } + } /* Actual command implementations. */ diff --git a/stratosphere/pm/source/pm_info_service.hpp b/stratosphere/pm/source/pm_info_service.hpp index 70043aeb8..f46639b27 100644 --- a/stratosphere/pm/source/pm_info_service.hpp +++ b/stratosphere/pm/source/pm_info_service.hpp @@ -16,18 +16,10 @@ #pragma once #include -namespace ams::pm::info { +namespace ams::pm { - class InformationService final : public sf::IServiceObject { - private: - enum class CommandId { - GetProgramId = 0, - - AtmosphereGetProcessId = 65000, - AtmosphereHasLaunchedProgram = 65001, - AtmosphereGetProcessInfo = 65002, - }; - private: + class InformationService final { + public: /* Actual command implementations. */ Result GetProgramId(sf::Out out, os::ProcessId process_id); @@ -35,14 +27,7 @@ namespace ams::pm::info { Result AtmosphereGetProcessId(sf::Out out, ncm::ProgramId program_id); Result AtmosphereHasLaunchedProgram(sf::Out out, ncm::ProgramId program_id); Result AtmosphereGetProcessInfo(sf::Out out_loc, sf::Out out_status, os::ProcessId process_id); - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(GetProgramId), - - MAKE_SERVICE_COMMAND_META(AtmosphereGetProcessId), - MAKE_SERVICE_COMMAND_META(AtmosphereHasLaunchedProgram), - MAKE_SERVICE_COMMAND_META(AtmosphereGetProcessInfo), - }; }; + static_assert(pm::impl::IsIInformationInterface); } diff --git a/stratosphere/pm/source/pm_main.cpp b/stratosphere/pm/source/pm_main.cpp index ae7078c32..a14bed856 100644 --- a/stratosphere/pm/source/pm_main.cpp +++ b/stratosphere/pm/source/pm_main.cpp @@ -196,14 +196,14 @@ int main(int argc, char **argv) /* NOTE: Extra sessions have been added to pm:bm and pm:info to facilitate access by the rest of stratosphere. */ /* Also Note: PM was rewritten in 5.0.0, so the shell and dmnt services are different before/after. */ if (hos::GetVersion() >= hos::Version_5_0_0) { - R_ABORT_UNLESS((g_server_manager.RegisterServer(ShellServiceName, ShellMaxSessions))); - R_ABORT_UNLESS((g_server_manager.RegisterServer(DebugMonitorServiceName, DebugMonitorMaxSessions))); + R_ABORT_UNLESS((g_server_manager.RegisterServer(ShellServiceName, ShellMaxSessions))); + R_ABORT_UNLESS((g_server_manager.RegisterServer(DebugMonitorServiceName, DebugMonitorMaxSessions))); } else { - R_ABORT_UNLESS((g_server_manager.RegisterServer(ShellServiceName, ShellMaxSessions))); - R_ABORT_UNLESS((g_server_manager.RegisterServer(DebugMonitorServiceName, DebugMonitorMaxSessions))); + R_ABORT_UNLESS((g_server_manager.RegisterServer(ShellServiceName, ShellMaxSessions))); + R_ABORT_UNLESS((g_server_manager.RegisterServer(DebugMonitorServiceName, DebugMonitorMaxSessions))); } - R_ABORT_UNLESS((g_server_manager.RegisterServer(BootModeServiceName, BootModeMaxSessions))); - R_ABORT_UNLESS((g_server_manager.RegisterServer(InformationServiceName, InformationMaxSessions))); + R_ABORT_UNLESS((g_server_manager.RegisterServer(BootModeServiceName, BootModeMaxSessions))); + R_ABORT_UNLESS((g_server_manager.RegisterServer(InformationServiceName, InformationMaxSessions))); /* Loop forever, servicing our services. */ g_server_manager.LoopProcess(); diff --git a/stratosphere/pm/source/pm_shell_service.cpp b/stratosphere/pm/source/pm_shell_service.cpp index 939066dea..491c3169f 100644 --- a/stratosphere/pm/source/pm_shell_service.cpp +++ b/stratosphere/pm/source/pm_shell_service.cpp @@ -17,59 +17,63 @@ #include "pm_shell_service.hpp" #include "impl/pm_process_manager.hpp" -namespace ams::pm::shell { +namespace ams::pm { /* Overrides for libstratosphere pm::shell commands. */ - Result LaunchProgram(os::ProcessId *out_process_id, const ncm::ProgramLocation &loc, u32 launch_flags) { - return impl::LaunchProgram(out_process_id, loc, launch_flags); + namespace shell { + + Result LaunchProgram(os::ProcessId *out_process_id, const ncm::ProgramLocation &loc, u32 launch_flags) { + return impl::LaunchProgram(out_process_id, loc, launch_flags); + } + } /* Service command implementations. */ - Result ShellServiceBase::LaunchProgram(sf::Out out_process_id, const ncm::ProgramLocation &loc, u32 flags) { + Result ShellService::LaunchProgram(sf::Out out_process_id, const ncm::ProgramLocation &loc, u32 flags) { return pm::shell::LaunchProgram(out_process_id.GetPointer(), loc, flags); } - Result ShellServiceBase::TerminateProcess(os::ProcessId process_id) { + Result ShellService::TerminateProcess(os::ProcessId process_id) { return impl::TerminateProcess(process_id); } - Result ShellServiceBase::TerminateProgram(ncm::ProgramId program_id) { + Result ShellService::TerminateProgram(ncm::ProgramId program_id) { return impl::TerminateProgram(program_id); } - void ShellServiceBase::GetProcessEventHandle(sf::OutCopyHandle out) { + void ShellService::GetProcessEventHandle(sf::OutCopyHandle out) { R_ABORT_UNLESS(impl::GetProcessEventHandle(out.GetHandlePointer())); } - void ShellServiceBase::GetProcessEventInfo(sf::Out out) { + void ShellService::GetProcessEventInfo(sf::Out out) { R_ABORT_UNLESS(impl::GetProcessEventInfo(out.GetPointer())); } - Result ShellServiceBase::CleanupProcess(os::ProcessId process_id) { + Result ShellService::CleanupProcess(os::ProcessId process_id) { return impl::CleanupProcess(process_id); } - Result ShellServiceBase::ClearExceptionOccurred(os::ProcessId process_id) { + Result ShellService::ClearExceptionOccurred(os::ProcessId process_id) { return impl::ClearExceptionOccurred(process_id); } - void ShellServiceBase::NotifyBootFinished() { + void ShellService::NotifyBootFinished() { R_ABORT_UNLESS(impl::NotifyBootFinished()); } - Result ShellServiceBase::GetApplicationProcessIdForShell(sf::Out out) { + Result ShellService::GetApplicationProcessIdForShell(sf::Out out) { return impl::GetApplicationProcessId(out.GetPointer()); } - Result ShellServiceBase::BoostSystemMemoryResourceLimit(u64 boost_size) { + Result ShellService::BoostSystemMemoryResourceLimit(u64 boost_size) { return impl::BoostSystemMemoryResourceLimit(boost_size); } - Result ShellServiceBase::BoostApplicationThreadResourceLimit() { + Result ShellService::BoostApplicationThreadResourceLimit() { return impl::BoostApplicationThreadResourceLimit(); } - void ShellServiceBase::GetBootFinishedEventHandle(sf::OutCopyHandle out) { + void ShellService::GetBootFinishedEventHandle(sf::OutCopyHandle out) { R_ABORT_UNLESS(impl::GetBootFinishedEventHandle(out.GetHandlePointer())); } diff --git a/stratosphere/pm/source/pm_shell_service.hpp b/stratosphere/pm/source/pm_shell_service.hpp index 7c0d60c07..8794eedd4 100644 --- a/stratosphere/pm/source/pm_shell_service.hpp +++ b/stratosphere/pm/source/pm_shell_service.hpp @@ -16,91 +16,24 @@ #pragma once #include -namespace ams::pm::shell { +namespace ams::pm { - class ShellServiceBase : public sf::IServiceObject { - protected: + class ShellService final { + public: /* Actual command implementations. */ - virtual Result LaunchProgram(sf::Out out_process_id, const ncm::ProgramLocation &loc, u32 flags); - virtual Result TerminateProcess(os::ProcessId process_id); - virtual Result TerminateProgram(ncm::ProgramId program_id); - virtual void GetProcessEventHandle(sf::OutCopyHandle out); - virtual void GetProcessEventInfo(sf::Out out); - virtual Result CleanupProcess(os::ProcessId process_id); - virtual Result ClearExceptionOccurred(os::ProcessId process_id); - virtual void NotifyBootFinished(); - virtual Result GetApplicationProcessIdForShell(sf::Out out); - virtual Result BoostSystemMemoryResourceLimit(u64 boost_size); - virtual Result BoostApplicationThreadResourceLimit(); - virtual void GetBootFinishedEventHandle(sf::OutCopyHandle out); - }; - - /* This represents modern ShellService (5.0.0+). */ - class ShellService final : public ShellServiceBase { - private: - enum class CommandId { - LaunchProgram = 0, - TerminateProcess = 1, - TerminateProgram = 2, - GetProcessEventHandle = 3, - GetProcessEventInfo = 4, - NotifyBootFinished = 5, - GetApplicationProcessIdForShell = 6, - BoostSystemMemoryResourceLimit = 7, - BoostApplicationThreadResourceLimit = 8, - GetBootFinishedEventHandle = 9, - }; - public: - DEFINE_SERVICE_DISPATCH_TABLE { - /* 5.0.0-* */ - MAKE_SERVICE_COMMAND_META(LaunchProgram), - MAKE_SERVICE_COMMAND_META(TerminateProcess), - MAKE_SERVICE_COMMAND_META(TerminateProgram), - MAKE_SERVICE_COMMAND_META(GetProcessEventHandle), - MAKE_SERVICE_COMMAND_META(GetProcessEventInfo), - MAKE_SERVICE_COMMAND_META(NotifyBootFinished), - MAKE_SERVICE_COMMAND_META(GetApplicationProcessIdForShell), - MAKE_SERVICE_COMMAND_META(BoostSystemMemoryResourceLimit), - - /* 7.0.0-* */ - MAKE_SERVICE_COMMAND_META(BoostApplicationThreadResourceLimit, hos::Version_7_0_0), - - /* 8.0.0-* */ - MAKE_SERVICE_COMMAND_META(GetBootFinishedEventHandle, hos::Version_8_0_0), - }; - }; - - /* This represents deprecated ShellService (1.0.0-4.1.0). */ - class ShellServiceDeprecated final : public ShellServiceBase { - private: - enum class CommandId { - LaunchProgram = 0, - TerminateProcess = 1, - TerminateProgram = 2, - GetProcessEventHandle = 3, - GetProcessEventInfo = 4, - CleanupProcess = 5, - ClearExceptionOccurred = 6, - NotifyBootFinished = 7, - GetApplicationProcessIdForShell = 8, - BoostSystemMemoryResourceLimit = 9, - }; - public: - DEFINE_SERVICE_DISPATCH_TABLE { - /* 1.0.0-4.1.0 */ - MAKE_SERVICE_COMMAND_META(LaunchProgram), - MAKE_SERVICE_COMMAND_META(TerminateProcess), - MAKE_SERVICE_COMMAND_META(TerminateProgram), - MAKE_SERVICE_COMMAND_META(GetProcessEventHandle), - MAKE_SERVICE_COMMAND_META(GetProcessEventInfo), - MAKE_SERVICE_COMMAND_META(CleanupProcess), - MAKE_SERVICE_COMMAND_META(ClearExceptionOccurred), - MAKE_SERVICE_COMMAND_META(NotifyBootFinished), - MAKE_SERVICE_COMMAND_META(GetApplicationProcessIdForShell), - - /* 4.0.0-4.1.0 */ - MAKE_SERVICE_COMMAND_META(BoostSystemMemoryResourceLimit, hos::Version_4_0_0), - }; + Result LaunchProgram(sf::Out out_process_id, const ncm::ProgramLocation &loc, u32 flags); + Result TerminateProcess(os::ProcessId process_id); + Result TerminateProgram(ncm::ProgramId program_id); + void GetProcessEventHandle(sf::OutCopyHandle out); + void GetProcessEventInfo(sf::Out out); + Result CleanupProcess(os::ProcessId process_id); + Result ClearExceptionOccurred(os::ProcessId process_id); + void NotifyBootFinished(); + Result GetApplicationProcessIdForShell(sf::Out out); + Result BoostSystemMemoryResourceLimit(u64 boost_size); + Result BoostApplicationThreadResourceLimit(); + void GetBootFinishedEventHandle(sf::OutCopyHandle out); }; + static_assert(pm::impl::IsIShellInterface); }