mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-08-25 22:37:19 +02:00
Deglobalize System: Fatal
This commit is contained in:
parent
c33faabb27
commit
a40e5b2def
@ -20,8 +20,8 @@
|
||||
|
||||
namespace Service::Fatal {
|
||||
|
||||
Module::Interface::Interface(std::shared_ptr<Module> module, const char* name)
|
||||
: ServiceFramework(name), module(std::move(module)) {}
|
||||
Module::Interface::Interface(std::shared_ptr<Module> module, Core::System& system, const char* name)
|
||||
: ServiceFramework(name), module(std::move(module)), system(system) {}
|
||||
|
||||
Module::Interface::~Interface() = default;
|
||||
|
||||
@ -64,7 +64,8 @@ enum class FatalType : u32 {
|
||||
ErrorScreen = 2,
|
||||
};
|
||||
|
||||
static void GenerateErrorReport(ResultCode error_code, const FatalInfo& info) {
|
||||
static void GenerateErrorReport(Core::System& system, ResultCode error_code,
|
||||
const FatalInfo& info) {
|
||||
const auto title_id = Core::CurrentProcess()->GetTitleID();
|
||||
std::string crash_report = fmt::format(
|
||||
"Yuzu {}-{} crash report\n"
|
||||
@ -101,18 +102,19 @@ static void GenerateErrorReport(ResultCode error_code, const FatalInfo& info) {
|
||||
|
||||
LOG_ERROR(Service_Fatal, "{}", crash_report);
|
||||
|
||||
Core::System::GetInstance().GetReporter().SaveCrashReport(
|
||||
system.GetReporter().SaveCrashReport(
|
||||
title_id, error_code, info.set_flags, info.program_entry_point, info.sp, info.pc,
|
||||
info.pstate, info.afsr0, info.afsr1, info.esr, info.far, info.registers, info.backtrace,
|
||||
info.backtrace_size, info.ArchAsString(), info.unk10);
|
||||
}
|
||||
|
||||
static void ThrowFatalError(ResultCode error_code, FatalType fatal_type, const FatalInfo& info) {
|
||||
static void ThrowFatalError(Core::System& system, ResultCode error_code, FatalType fatal_type,
|
||||
const FatalInfo& info) {
|
||||
LOG_ERROR(Service_Fatal, "Threw fatal error type {} with error code 0x{:X}",
|
||||
static_cast<u32>(fatal_type), error_code.raw);
|
||||
switch (fatal_type) {
|
||||
case FatalType::ErrorReportAndScreen:
|
||||
GenerateErrorReport(error_code, info);
|
||||
GenerateErrorReport(system, error_code, info);
|
||||
[[fallthrough]];
|
||||
case FatalType::ErrorScreen:
|
||||
// Since we have no fatal:u error screen. We should just kill execution instead
|
||||
@ -120,7 +122,7 @@ static void ThrowFatalError(ResultCode error_code, FatalType fatal_type, const F
|
||||
break;
|
||||
// Should not throw a fatal screen but should generate an error report
|
||||
case FatalType::ErrorReport:
|
||||
GenerateErrorReport(error_code, info);
|
||||
GenerateErrorReport(system, error_code, info);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -130,7 +132,7 @@ void Module::Interface::ThrowFatal(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto error_code = rp.Pop<ResultCode>();
|
||||
|
||||
ThrowFatalError(error_code, FatalType::ErrorScreen, {});
|
||||
ThrowFatalError(system, error_code, FatalType::ErrorScreen, {});
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
}
|
||||
@ -141,7 +143,8 @@ void Module::Interface::ThrowFatalWithPolicy(Kernel::HLERequestContext& ctx) {
|
||||
const auto error_code = rp.Pop<ResultCode>();
|
||||
const auto fatal_type = rp.PopEnum<FatalType>();
|
||||
|
||||
ThrowFatalError(error_code, fatal_type, {}); // No info is passed with ThrowFatalWithPolicy
|
||||
ThrowFatalError(system, error_code, fatal_type,
|
||||
{}); // No info is passed with ThrowFatalWithPolicy
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
}
|
||||
@ -157,15 +160,15 @@ void Module::Interface::ThrowFatalWithCpuContext(Kernel::HLERequestContext& ctx)
|
||||
ASSERT_MSG(fatal_info.size() == sizeof(FatalInfo), "Invalid fatal info buffer size!");
|
||||
std::memcpy(&info, fatal_info.data(), sizeof(FatalInfo));
|
||||
|
||||
ThrowFatalError(error_code, fatal_type, info);
|
||||
ThrowFatalError(system, error_code, fatal_type, info);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
void InstallInterfaces(SM::ServiceManager& service_manager) {
|
||||
void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
|
||||
auto module = std::make_shared<Module>();
|
||||
std::make_shared<Fatal_P>(module)->InstallAsService(service_manager);
|
||||
std::make_shared<Fatal_U>(module)->InstallAsService(service_manager);
|
||||
std::make_shared<Fatal_P>(module, system)->InstallAsService(service_manager);
|
||||
std::make_shared<Fatal_U>(module, system)->InstallAsService(service_manager);
|
||||
}
|
||||
|
||||
} // namespace Service::Fatal
|
||||
|
@ -6,13 +6,17 @@
|
||||
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Service::Fatal {
|
||||
|
||||
class Module final {
|
||||
public:
|
||||
class Interface : public ServiceFramework<Interface> {
|
||||
public:
|
||||
explicit Interface(std::shared_ptr<Module> module, const char* name);
|
||||
explicit Interface(std::shared_ptr<Module> module, Core::System& system, const char* name);
|
||||
~Interface() override;
|
||||
|
||||
void ThrowFatal(Kernel::HLERequestContext& ctx);
|
||||
@ -21,9 +25,10 @@ public:
|
||||
|
||||
protected:
|
||||
std::shared_ptr<Module> module;
|
||||
Core::System& system;
|
||||
};
|
||||
};
|
||||
|
||||
void InstallInterfaces(SM::ServiceManager& service_manager);
|
||||
void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system);
|
||||
|
||||
} // namespace Service::Fatal
|
||||
|
@ -6,8 +6,8 @@
|
||||
|
||||
namespace Service::Fatal {
|
||||
|
||||
Fatal_P::Fatal_P(std::shared_ptr<Module> module)
|
||||
: Module::Interface(std::move(module), "fatal:p") {}
|
||||
Fatal_P::Fatal_P(std::shared_ptr<Module> module, Core::System& system)
|
||||
: Module::Interface(std::move(module), system, "fatal:p") {}
|
||||
|
||||
Fatal_P::~Fatal_P() = default;
|
||||
|
||||
|
@ -10,7 +10,7 @@ namespace Service::Fatal {
|
||||
|
||||
class Fatal_P final : public Module::Interface {
|
||||
public:
|
||||
explicit Fatal_P(std::shared_ptr<Module> module);
|
||||
explicit Fatal_P(std::shared_ptr<Module> module, Core::System& system);
|
||||
~Fatal_P() override;
|
||||
};
|
||||
|
||||
|
@ -6,7 +6,8 @@
|
||||
|
||||
namespace Service::Fatal {
|
||||
|
||||
Fatal_U::Fatal_U(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "fatal:u") {
|
||||
Fatal_U::Fatal_U(std::shared_ptr<Module> module, Core::System& system)
|
||||
: Module::Interface(std::move(module), system, "fatal:u") {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &Fatal_U::ThrowFatal, "ThrowFatal"},
|
||||
{1, &Fatal_U::ThrowFatalWithPolicy, "ThrowFatalWithPolicy"},
|
||||
|
@ -10,7 +10,7 @@ namespace Service::Fatal {
|
||||
|
||||
class Fatal_U final : public Module::Interface {
|
||||
public:
|
||||
explicit Fatal_U(std::shared_ptr<Module> module);
|
||||
explicit Fatal_U(std::shared_ptr<Module> module, Core::System& system);
|
||||
~Fatal_U() override;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user