// 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, std::shared_ptr &logger, std::shared_ptr &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(romFd)}; auto keyStore{std::make_shared(appFilesPath)}; if (romType == loader::RomFormat::NRO) state.loader = std::make_shared(romFile); else if (romType == loader::RomFormat::NSO) state.loader = std::make_shared(romFile); else if (romType == loader::RomFormat::NCA) state.loader = std::make_shared(romFile, keyStore); else if (romType == loader::RomFormat::NSP) state.loader = std::make_shared(romFile, keyStore); else throw exception("Unsupported ROM extension."); auto &process{state.process}; process = std::make_shared(state); auto entry{state.loader->LoadProcessData(process, state)}; process->InitializeHeap(); auto thread{process->CreateThread(entry)}; if (thread) { thread->Start(true); process->Kill(true, true, true); } } }