sf: update fatal for new format

This commit is contained in:
Michael Scire 2020-07-07 05:14:55 -07:00
parent dec1f7fba2
commit c32bd7ca38
6 changed files with 75 additions and 33 deletions

View file

@ -16,4 +16,7 @@
#pragma once
#include "fatal/fatal_types.hpp"
#include <stratosphere/fatal/fatal_types.hpp>
#include <stratosphere/fatal/impl/fatal_i_service.hpp>
#include <stratosphere/fatal/impl/fatal_i_private_service.hpp>

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/fatal/fatal_types.hpp>
#include <stratosphere/sf.hpp>
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)
}

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/fatal/fatal_types.hpp>
#include <stratosphere/sf.hpp>
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)
}

View file

@ -156,11 +156,10 @@ int main(int argc, char **argv)
fatal::srv::CheckRepairStatus();
/* Create services. */
R_ABORT_UNLESS((g_server_manager.RegisterServer<fatal::srv::PrivateService>(PrivateServiceName, PrivateMaxSessions)));
R_ABORT_UNLESS((g_server_manager.RegisterServer<fatal::srv::UserService>(UserServiceName, UserMaxSessions)));
R_ABORT_UNLESS((g_server_manager.RegisterServer<fatal::impl::IPrivateService, fatal::srv::PrivateService>(PrivateServiceName, PrivateMaxSessions)));
R_ABORT_UNLESS((g_server_manager.RegisterServer<fatal::impl::IService, fatal::srv::Service>(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);

View file

@ -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);
}

View file

@ -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<Service>);
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<PrivateService>);
}