From c32bd7ca3861cbe5dc1eae6e69fa0ca23340a566 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Tue, 7 Jul 2020 05:14:55 -0700 Subject: [PATCH] sf: update fatal for new format --- .../include/stratosphere/fatal.hpp | 5 ++- .../fatal/impl/fatal_i_private_service.hpp | 29 +++++++++++++++++ .../fatal/impl/fatal_i_service.hpp | 31 ++++++++++++++++++ stratosphere/fatal/source/fatal_main.cpp | 5 ++- stratosphere/fatal/source/fatal_service.cpp | 6 ++-- stratosphere/fatal/source/fatal_service.hpp | 32 ++++--------------- 6 files changed, 75 insertions(+), 33 deletions(-) create mode 100644 libraries/libstratosphere/include/stratosphere/fatal/impl/fatal_i_private_service.hpp create mode 100644 libraries/libstratosphere/include/stratosphere/fatal/impl/fatal_i_service.hpp diff --git a/libraries/libstratosphere/include/stratosphere/fatal.hpp b/libraries/libstratosphere/include/stratosphere/fatal.hpp index 52ad0b054..00025c562 100644 --- a/libraries/libstratosphere/include/stratosphere/fatal.hpp +++ b/libraries/libstratosphere/include/stratosphere/fatal.hpp @@ -16,4 +16,7 @@ #pragma once -#include "fatal/fatal_types.hpp" +#include + +#include +#include diff --git a/libraries/libstratosphere/include/stratosphere/fatal/impl/fatal_i_private_service.hpp b/libraries/libstratosphere/include/stratosphere/fatal/impl/fatal_i_private_service.hpp new file mode 100644 index 000000000..59e2b70bc --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/fatal/impl/fatal_i_private_service.hpp @@ -0,0 +1,29 @@ +/* + * 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::fatal::impl { + + #define AMS_FATAL_I_PRIVATE_SERVICE_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, GetFatalEvent, (sf::OutCopyHandle out_h)) + + AMS_SF_DEFINE_INTERFACE(IPrivateService, AMS_FATAL_I_PRIVATE_SERVICE_INTERFACE_INFO) + +} diff --git a/libraries/libstratosphere/include/stratosphere/fatal/impl/fatal_i_service.hpp b/libraries/libstratosphere/include/stratosphere/fatal/impl/fatal_i_service.hpp new file mode 100644 index 000000000..36922e786 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/fatal/impl/fatal_i_service.hpp @@ -0,0 +1,31 @@ +/* + * 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::fatal::impl { + + #define AMS_FATAL_I_SERVICE_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, ThrowFatal, (Result error, const sf::ClientProcessId &client_pid)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, ThrowFatalWithPolicy, (Result error, const sf::ClientProcessId &client_pid, FatalPolicy policy)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, ThrowFatalWithCpuContext, (Result error, const sf::ClientProcessId &client_pid, FatalPolicy policy, const CpuContext &cpu_ctx)) + + AMS_SF_DEFINE_INTERFACE(IService, AMS_FATAL_I_SERVICE_INTERFACE_INFO) + +} diff --git a/stratosphere/fatal/source/fatal_main.cpp b/stratosphere/fatal/source/fatal_main.cpp index 587c40f4a..3b576347b 100644 --- a/stratosphere/fatal/source/fatal_main.cpp +++ b/stratosphere/fatal/source/fatal_main.cpp @@ -156,11 +156,10 @@ int main(int argc, char **argv) fatal::srv::CheckRepairStatus(); /* Create services. */ - R_ABORT_UNLESS((g_server_manager.RegisterServer(PrivateServiceName, PrivateMaxSessions))); - R_ABORT_UNLESS((g_server_manager.RegisterServer(UserServiceName, UserMaxSessions))); + R_ABORT_UNLESS((g_server_manager.RegisterServer(PrivateServiceName, PrivateMaxSessions))); + R_ABORT_UNLESS((g_server_manager.RegisterServer(UserServiceName, UserMaxSessions))); /* Add dirty event holder. */ - /* TODO: s_server_manager.AddWaitable(ams::fatal::srv::GetFatalDirtyEvent()); */ auto *dirty_event_holder = ams::fatal::srv::GetFatalDirtyWaitableHolder(); g_server_manager.AddUserWaitableHolder(dirty_event_holder); diff --git a/stratosphere/fatal/source/fatal_service.cpp b/stratosphere/fatal/source/fatal_service.cpp index 0e86883b6..5c0744c35 100644 --- a/stratosphere/fatal/source/fatal_service.cpp +++ b/stratosphere/fatal/source/fatal_service.cpp @@ -133,15 +133,15 @@ namespace ams::fatal::srv { return g_context.ThrowFatalWithPolicy(result, os::GetCurrentProcessId(), FatalPolicy_ErrorScreen); } - Result UserService::ThrowFatal(Result result, const sf::ClientProcessId &client_pid) { + Result Service::ThrowFatal(Result result, const sf::ClientProcessId &client_pid) { return g_context.ThrowFatal(result, client_pid.GetValue()); } - Result UserService::ThrowFatalWithPolicy(Result result, const sf::ClientProcessId &client_pid, FatalPolicy policy) { + Result Service::ThrowFatalWithPolicy(Result result, const sf::ClientProcessId &client_pid, FatalPolicy policy) { return g_context.ThrowFatalWithPolicy(result, client_pid.GetValue(), policy); } - Result UserService::ThrowFatalWithCpuContext(Result result, const sf::ClientProcessId &client_pid, FatalPolicy policy, const CpuContext &cpu_ctx) { + Result Service::ThrowFatalWithCpuContext(Result result, const sf::ClientProcessId &client_pid, FatalPolicy policy, const CpuContext &cpu_ctx) { return g_context.ThrowFatalWithCpuContext(result, client_pid.GetValue(), policy, cpu_ctx); } diff --git a/stratosphere/fatal/source/fatal_service.hpp b/stratosphere/fatal/source/fatal_service.hpp index 04c707e0a..ca20c5e9f 100644 --- a/stratosphere/fatal/source/fatal_service.hpp +++ b/stratosphere/fatal/source/fatal_service.hpp @@ -18,39 +18,19 @@ namespace ams::fatal::srv { - class UserService final : public sf::IServiceObject { - private: - enum class CommandId { - ThrowFatal = 0, - ThrowFatalWithPolicy = 1, - ThrowFatalWithCpuContext = 2, - }; - private: - /* Actual commands. */ + class Service final { + public: Result ThrowFatal(Result error, const sf::ClientProcessId &client_pid); Result ThrowFatalWithPolicy(Result error, const sf::ClientProcessId &client_pid, FatalPolicy policy); Result ThrowFatalWithCpuContext(Result error, const sf::ClientProcessId &client_pid, FatalPolicy policy, const CpuContext &cpu_ctx); - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(ThrowFatal), - MAKE_SERVICE_COMMAND_META(ThrowFatalWithPolicy), - MAKE_SERVICE_COMMAND_META(ThrowFatalWithCpuContext), - }; }; + static_assert(fatal::impl::IsIService); - class PrivateService final : public sf::IServiceObject { - private: - enum class CommandId { - GetFatalEvent = 0, - }; - private: - /* Actual commands. */ - Result GetFatalEvent(sf::OutCopyHandle out_h); + class PrivateService final { public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(GetFatalEvent), - }; + Result GetFatalEvent(sf::OutCopyHandle out_h); }; + static_assert(fatal::impl::IsIPrivateService); }