mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-06-02 04:08:46 +02:00
668f623256
An exceptional signal handler allows us to convert an OS signal into a C++ exception, this allows us to alleviate a lot of crashes that would otherwise occur from signals being thrown during execution of games and be able to handle them gracefully.
39 lines
1.6 KiB
C++
39 lines
1.6 KiB
C++
// SPDX-License-Identifier: MPL-2.0
|
|
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
|
|
|
#include "nce.h"
|
|
#include "nce/guest.h"
|
|
#include "kernel/types/KProcess.h"
|
|
#include "vfs/os_backing.h"
|
|
#include "loader/nro.h"
|
|
#include "loader/nso.h"
|
|
#include "loader/nca.h"
|
|
#include "loader/nsp.h"
|
|
#include "os.h"
|
|
|
|
namespace skyline::kernel {
|
|
OS::OS(std::shared_ptr<JvmManager> &jvmManager, std::shared_ptr<Logger> &logger, std::shared_ptr<Settings> &settings, const std::string &appFilesPath) : state(this, jvmManager, settings, logger), serviceManager(state), appFilesPath(appFilesPath) {}
|
|
|
|
void OS::Execute(int romFd, loader::RomFormat romType) {
|
|
auto romFile{std::make_shared<vfs::OsBacking>(romFd)};
|
|
auto keyStore{std::make_shared<crypto::KeyStore>(appFilesPath)};
|
|
|
|
if (romType == loader::RomFormat::NRO)
|
|
state.loader = std::make_shared<loader::NroLoader>(romFile);
|
|
else if (romType == loader::RomFormat::NSO)
|
|
state.loader = std::make_shared<loader::NsoLoader>(romFile);
|
|
else if (romType == loader::RomFormat::NCA)
|
|
state.loader = std::make_shared<loader::NcaLoader>(romFile, keyStore);
|
|
else if (romType == loader::RomFormat::NSP)
|
|
state.loader = std::make_shared<loader::NspLoader>(romFile, keyStore);
|
|
else
|
|
throw exception("Unsupported ROM extension.");
|
|
|
|
auto& process{state.process};
|
|
process = std::make_shared<kernel::type::KProcess>(state);
|
|
auto entry{state.loader->LoadProcessData(process, state)};
|
|
process->InitializeHeap();
|
|
process->CreateThread(entry)->Start(true);
|
|
}
|
|
}
|