mirror of
https://gitlab.com/suyu-emu/suyu.git
synced 2024-03-15 23:15:44 +00:00
core/loader: Remove dependencies on the global system instance
Now all that remains is: 18 instances in file_sys code 14 instances in GDB stub code (this can be tossed wholesale) 4 instances in HLE code 2 instances in settings code.
This commit is contained in:
parent
004bfefeb5
commit
113a3972a6
|
@ -221,7 +221,7 @@ struct System::Impl {
|
||||||
telemetry_session->AddInitialInfo(*app_loader);
|
telemetry_session->AddInitialInfo(*app_loader);
|
||||||
auto main_process =
|
auto main_process =
|
||||||
Kernel::Process::Create(system, "main", Kernel::Process::ProcessType::Userland);
|
Kernel::Process::Create(system, "main", Kernel::Process::ProcessType::Userland);
|
||||||
const auto [load_result, load_parameters] = app_loader->Load(*main_process);
|
const auto [load_result, load_parameters] = app_loader->Load(*main_process, system);
|
||||||
if (load_result != Loader::ResultStatus::Success) {
|
if (load_result != Loader::ResultStatus::Success) {
|
||||||
LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", static_cast<int>(load_result));
|
LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", static_cast<int>(load_result));
|
||||||
Shutdown();
|
Shutdown();
|
||||||
|
|
|
@ -89,7 +89,7 @@ FileType AppLoader_DeconstructedRomDirectory::IdentifyType(const FileSys::Virtua
|
||||||
}
|
}
|
||||||
|
|
||||||
AppLoader_DeconstructedRomDirectory::LoadResult AppLoader_DeconstructedRomDirectory::Load(
|
AppLoader_DeconstructedRomDirectory::LoadResult AppLoader_DeconstructedRomDirectory::Load(
|
||||||
Kernel::Process& process) {
|
Kernel::Process& process, Core::System& system) {
|
||||||
if (is_loaded) {
|
if (is_loaded) {
|
||||||
return {ResultStatus::ErrorAlreadyLoaded, {}};
|
return {ResultStatus::ErrorAlreadyLoaded, {}};
|
||||||
}
|
}
|
||||||
|
@ -141,9 +141,9 @@ AppLoader_DeconstructedRomDirectory::LoadResult AppLoader_DeconstructedRomDirect
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool should_pass_arguments{std::strcmp(module, "rtld") == 0};
|
const bool should_pass_arguments = std::strcmp(module, "rtld") == 0;
|
||||||
const auto tentative_next_load_addr{AppLoader_NSO::LoadModule(
|
const auto tentative_next_load_addr = AppLoader_NSO::LoadModule(
|
||||||
process, *module_file, code_size, should_pass_arguments, false)};
|
process, system, *module_file, code_size, should_pass_arguments, false);
|
||||||
if (!tentative_next_load_addr) {
|
if (!tentative_next_load_addr) {
|
||||||
return {ResultStatus::ErrorLoadingNSO, {}};
|
return {ResultStatus::ErrorLoadingNSO, {}};
|
||||||
}
|
}
|
||||||
|
@ -168,9 +168,9 @@ AppLoader_DeconstructedRomDirectory::LoadResult AppLoader_DeconstructedRomDirect
|
||||||
}
|
}
|
||||||
|
|
||||||
const VAddr load_addr{next_load_addr};
|
const VAddr load_addr{next_load_addr};
|
||||||
const bool should_pass_arguments{std::strcmp(module, "rtld") == 0};
|
const bool should_pass_arguments = std::strcmp(module, "rtld") == 0;
|
||||||
const auto tentative_next_load_addr{AppLoader_NSO::LoadModule(
|
const auto tentative_next_load_addr = AppLoader_NSO::LoadModule(
|
||||||
process, *module_file, load_addr, should_pass_arguments, true, pm)};
|
process, system, *module_file, load_addr, should_pass_arguments, true, pm);
|
||||||
if (!tentative_next_load_addr) {
|
if (!tentative_next_load_addr) {
|
||||||
return {ResultStatus::ErrorLoadingNSO, {}};
|
return {ResultStatus::ErrorLoadingNSO, {}};
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ AppLoader_DeconstructedRomDirectory::LoadResult AppLoader_DeconstructedRomDirect
|
||||||
// Register the RomFS if a ".romfs" file was found
|
// Register the RomFS if a ".romfs" file was found
|
||||||
if (romfs_iter != files.end() && *romfs_iter != nullptr) {
|
if (romfs_iter != files.end() && *romfs_iter != nullptr) {
|
||||||
romfs = *romfs_iter;
|
romfs = *romfs_iter;
|
||||||
Core::System::GetInstance().GetFileSystemController().RegisterRomFS(
|
system.GetFileSystemController().RegisterRomFS(
|
||||||
std::make_unique<FileSys::RomFSFactory>(*this));
|
std::make_unique<FileSys::RomFSFactory>(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,10 @@
|
||||||
#include "core/file_sys/program_metadata.h"
|
#include "core/file_sys/program_metadata.h"
|
||||||
#include "core/loader/loader.h"
|
#include "core/loader/loader.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Loader {
|
namespace Loader {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +41,7 @@ public:
|
||||||
return IdentifyType(file);
|
return IdentifyType(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadResult Load(Kernel::Process& process) override;
|
LoadResult Load(Kernel::Process& process, Core::System& system) override;
|
||||||
|
|
||||||
ResultStatus ReadRomFS(FileSys::VirtualFile& dir) override;
|
ResultStatus ReadRomFS(FileSys::VirtualFile& dir) override;
|
||||||
ResultStatus ReadIcon(std::vector<u8>& buffer) override;
|
ResultStatus ReadIcon(std::vector<u8>& buffer) override;
|
||||||
|
|
|
@ -383,7 +383,8 @@ FileType AppLoader_ELF::IdentifyType(const FileSys::VirtualFile& file) {
|
||||||
return FileType::Error;
|
return FileType::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
AppLoader_ELF::LoadResult AppLoader_ELF::Load(Kernel::Process& process) {
|
AppLoader_ELF::LoadResult AppLoader_ELF::Load(Kernel::Process& process,
|
||||||
|
[[maybe_unused]] Core::System& system) {
|
||||||
if (is_loaded) {
|
if (is_loaded) {
|
||||||
return {ResultStatus::ErrorAlreadyLoaded, {}};
|
return {ResultStatus::ErrorAlreadyLoaded, {}};
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,10 @@
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "core/loader/loader.h"
|
#include "core/loader/loader.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Loader {
|
namespace Loader {
|
||||||
|
|
||||||
/// Loads an ELF/AXF file
|
/// Loads an ELF/AXF file
|
||||||
|
@ -26,7 +30,7 @@ public:
|
||||||
return IdentifyType(file);
|
return IdentifyType(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadResult Load(Kernel::Process& process) override;
|
LoadResult Load(Kernel::Process& process, Core::System& system) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Loader
|
} // namespace Loader
|
||||||
|
|
|
@ -43,7 +43,8 @@ FileType AppLoader_KIP::GetFileType() const {
|
||||||
: FileType::Error;
|
: FileType::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
AppLoader::LoadResult AppLoader_KIP::Load(Kernel::Process& process) {
|
AppLoader::LoadResult AppLoader_KIP::Load(Kernel::Process& process,
|
||||||
|
[[maybe_unused]] Core::System& system) {
|
||||||
if (is_loaded) {
|
if (is_loaded) {
|
||||||
return {ResultStatus::ErrorAlreadyLoaded, {}};
|
return {ResultStatus::ErrorAlreadyLoaded, {}};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
|
|
||||||
#include "core/loader/loader.h"
|
#include "core/loader/loader.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
class KIP;
|
class KIP;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +30,7 @@ public:
|
||||||
|
|
||||||
FileType GetFileType() const override;
|
FileType GetFileType() const override;
|
||||||
|
|
||||||
LoadResult Load(Kernel::Process& process) override;
|
LoadResult Load(Kernel::Process& process, Core::System& system) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<FileSys::KIP> kip;
|
std::unique_ptr<FileSys::KIP> kip;
|
||||||
|
|
|
@ -15,6 +15,10 @@
|
||||||
#include "core/file_sys/control_metadata.h"
|
#include "core/file_sys/control_metadata.h"
|
||||||
#include "core/file_sys/vfs.h"
|
#include "core/file_sys/vfs.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
class NACP;
|
class NACP;
|
||||||
} // namespace FileSys
|
} // namespace FileSys
|
||||||
|
@ -154,9 +158,10 @@ public:
|
||||||
/**
|
/**
|
||||||
* Load the application and return the created Process instance
|
* Load the application and return the created Process instance
|
||||||
* @param process The newly created process.
|
* @param process The newly created process.
|
||||||
|
* @param system The system that this process is being loaded under.
|
||||||
* @return The status result of the operation.
|
* @return The status result of the operation.
|
||||||
*/
|
*/
|
||||||
virtual LoadResult Load(Kernel::Process& process) = 0;
|
virtual LoadResult Load(Kernel::Process& process, Core::System& system) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the code (typically .code section) of the application
|
* Get the code (typically .code section) of the application
|
||||||
|
|
|
@ -41,7 +41,8 @@ FileType AppLoader_NAX::GetFileType() const {
|
||||||
return IdentifyTypeImpl(*nax);
|
return IdentifyTypeImpl(*nax);
|
||||||
}
|
}
|
||||||
|
|
||||||
AppLoader_NAX::LoadResult AppLoader_NAX::Load(Kernel::Process& process) {
|
AppLoader_NAX::LoadResult AppLoader_NAX::Load(Kernel::Process& process,
|
||||||
|
[[maybe_unused]] Core::System& system) {
|
||||||
if (is_loaded) {
|
if (is_loaded) {
|
||||||
return {ResultStatus::ErrorAlreadyLoaded, {}};
|
return {ResultStatus::ErrorAlreadyLoaded, {}};
|
||||||
}
|
}
|
||||||
|
@ -65,7 +66,7 @@ AppLoader_NAX::LoadResult AppLoader_NAX::Load(Kernel::Process& process) {
|
||||||
return {nca_status, {}};
|
return {nca_status, {}};
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto result = nca_loader->Load(process);
|
const auto result = nca_loader->Load(process, system);
|
||||||
if (result.first != ResultStatus::Success) {
|
if (result.first != ResultStatus::Success) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,12 @@
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "core/loader/loader.h"
|
#include "core/loader/loader.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
|
|
||||||
class NAX;
|
class NAX;
|
||||||
|
|
||||||
} // namespace FileSys
|
} // namespace FileSys
|
||||||
|
|
||||||
namespace Loader {
|
namespace Loader {
|
||||||
|
@ -33,7 +35,7 @@ public:
|
||||||
|
|
||||||
FileType GetFileType() const override;
|
FileType GetFileType() const override;
|
||||||
|
|
||||||
LoadResult Load(Kernel::Process& process) override;
|
LoadResult Load(Kernel::Process& process, Core::System& system) override;
|
||||||
|
|
||||||
ResultStatus ReadRomFS(FileSys::VirtualFile& dir) override;
|
ResultStatus ReadRomFS(FileSys::VirtualFile& dir) override;
|
||||||
u64 ReadRomFSIVFCOffset() const override;
|
u64 ReadRomFSIVFCOffset() const override;
|
||||||
|
|
|
@ -31,7 +31,7 @@ FileType AppLoader_NCA::IdentifyType(const FileSys::VirtualFile& file) {
|
||||||
return FileType::Error;
|
return FileType::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
AppLoader_NCA::LoadResult AppLoader_NCA::Load(Kernel::Process& process) {
|
AppLoader_NCA::LoadResult AppLoader_NCA::Load(Kernel::Process& process, Core::System& system) {
|
||||||
if (is_loaded) {
|
if (is_loaded) {
|
||||||
return {ResultStatus::ErrorAlreadyLoaded, {}};
|
return {ResultStatus::ErrorAlreadyLoaded, {}};
|
||||||
}
|
}
|
||||||
|
@ -52,13 +52,13 @@ AppLoader_NCA::LoadResult AppLoader_NCA::Load(Kernel::Process& process) {
|
||||||
|
|
||||||
directory_loader = std::make_unique<AppLoader_DeconstructedRomDirectory>(exefs, true);
|
directory_loader = std::make_unique<AppLoader_DeconstructedRomDirectory>(exefs, true);
|
||||||
|
|
||||||
const auto load_result = directory_loader->Load(process);
|
const auto load_result = directory_loader->Load(process, system);
|
||||||
if (load_result.first != ResultStatus::Success) {
|
if (load_result.first != ResultStatus::Success) {
|
||||||
return load_result;
|
return load_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nca->GetRomFS() != nullptr && nca->GetRomFS()->GetSize() > 0) {
|
if (nca->GetRomFS() != nullptr && nca->GetRomFS()->GetSize() > 0) {
|
||||||
Core::System::GetInstance().GetFileSystemController().RegisterRomFS(
|
system.GetFileSystemController().RegisterRomFS(
|
||||||
std::make_unique<FileSys::RomFSFactory>(*this));
|
std::make_unique<FileSys::RomFSFactory>(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,10 @@
|
||||||
#include "core/file_sys/vfs.h"
|
#include "core/file_sys/vfs.h"
|
||||||
#include "core/loader/loader.h"
|
#include "core/loader/loader.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
class NCA;
|
class NCA;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +37,7 @@ public:
|
||||||
return IdentifyType(file);
|
return IdentifyType(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadResult Load(Kernel::Process& process) override;
|
LoadResult Load(Kernel::Process& process, Core::System& system) override;
|
||||||
|
|
||||||
ResultStatus ReadRomFS(FileSys::VirtualFile& dir) override;
|
ResultStatus ReadRomFS(FileSys::VirtualFile& dir) override;
|
||||||
u64 ReadRomFSIVFCOffset() const override;
|
u64 ReadRomFSIVFCOffset() const override;
|
||||||
|
|
|
@ -208,7 +208,7 @@ bool AppLoader_NRO::LoadNro(Kernel::Process& process, const FileSys::VfsFile& fi
|
||||||
return LoadNroImpl(process, file.ReadAllBytes(), file.GetName());
|
return LoadNroImpl(process, file.ReadAllBytes(), file.GetName());
|
||||||
}
|
}
|
||||||
|
|
||||||
AppLoader_NRO::LoadResult AppLoader_NRO::Load(Kernel::Process& process) {
|
AppLoader_NRO::LoadResult AppLoader_NRO::Load(Kernel::Process& process, Core::System& system) {
|
||||||
if (is_loaded) {
|
if (is_loaded) {
|
||||||
return {ResultStatus::ErrorAlreadyLoaded, {}};
|
return {ResultStatus::ErrorAlreadyLoaded, {}};
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,7 @@ AppLoader_NRO::LoadResult AppLoader_NRO::Load(Kernel::Process& process) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (romfs != nullptr) {
|
if (romfs != nullptr) {
|
||||||
Core::System::GetInstance().GetFileSystemController().RegisterRomFS(
|
system.GetFileSystemController().RegisterRomFS(
|
||||||
std::make_unique<FileSys::RomFSFactory>(*this));
|
std::make_unique<FileSys::RomFSFactory>(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "core/loader/loader.h"
|
#include "core/loader/loader.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
class NACP;
|
class NACP;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +41,7 @@ public:
|
||||||
return IdentifyType(file);
|
return IdentifyType(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadResult Load(Kernel::Process& process) override;
|
LoadResult Load(Kernel::Process& process, Core::System& system) override;
|
||||||
|
|
||||||
ResultStatus ReadIcon(std::vector<u8>& buffer) override;
|
ResultStatus ReadIcon(std::vector<u8>& buffer) override;
|
||||||
ResultStatus ReadProgramId(u64& out_program_id) override;
|
ResultStatus ReadProgramId(u64& out_program_id) override;
|
||||||
|
|
|
@ -71,7 +71,7 @@ FileType AppLoader_NSO::IdentifyType(const FileSys::VirtualFile& file) {
|
||||||
return FileType::NSO;
|
return FileType::NSO;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process,
|
std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process, Core::System& system,
|
||||||
const FileSys::VfsFile& file, VAddr load_base,
|
const FileSys::VfsFile& file, VAddr load_base,
|
||||||
bool should_pass_arguments, bool load_into_process,
|
bool should_pass_arguments, bool load_into_process,
|
||||||
std::optional<FileSys::PatchManager> pm) {
|
std::optional<FileSys::PatchManager> pm) {
|
||||||
|
@ -148,7 +148,6 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process,
|
||||||
|
|
||||||
// Apply cheats if they exist and the program has a valid title ID
|
// Apply cheats if they exist and the program has a valid title ID
|
||||||
if (pm) {
|
if (pm) {
|
||||||
auto& system = Core::System::GetInstance();
|
|
||||||
system.SetCurrentProcessBuildID(nso_header.build_id);
|
system.SetCurrentProcessBuildID(nso_header.build_id);
|
||||||
const auto cheats = pm->CreateCheatList(system, nso_header.build_id);
|
const auto cheats = pm->CreateCheatList(system, nso_header.build_id);
|
||||||
if (!cheats.empty()) {
|
if (!cheats.empty()) {
|
||||||
|
@ -166,7 +165,8 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process,
|
||||||
return load_base + image_size;
|
return load_base + image_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
AppLoader_NSO::LoadResult AppLoader_NSO::Load(Kernel::Process& process) {
|
AppLoader_NSO::LoadResult AppLoader_NSO::Load(Kernel::Process& process,
|
||||||
|
[[maybe_unused]] Core::System& system) {
|
||||||
if (is_loaded) {
|
if (is_loaded) {
|
||||||
return {ResultStatus::ErrorAlreadyLoaded, {}};
|
return {ResultStatus::ErrorAlreadyLoaded, {}};
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ AppLoader_NSO::LoadResult AppLoader_NSO::Load(Kernel::Process& process) {
|
||||||
|
|
||||||
// Load module
|
// Load module
|
||||||
const VAddr base_address = process.PageTable().GetCodeRegionStart();
|
const VAddr base_address = process.PageTable().GetCodeRegionStart();
|
||||||
if (!LoadModule(process, *file, base_address, true, true)) {
|
if (!LoadModule(process, system, *file, base_address, true, true)) {
|
||||||
return {ResultStatus::ErrorLoadingNSO, {}};
|
return {ResultStatus::ErrorLoadingNSO, {}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,10 @@
|
||||||
#include "core/file_sys/patch_manager.h"
|
#include "core/file_sys/patch_manager.h"
|
||||||
#include "core/loader/loader.h"
|
#include "core/loader/loader.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
class Process;
|
class Process;
|
||||||
}
|
}
|
||||||
|
@ -80,12 +84,12 @@ public:
|
||||||
return IdentifyType(file);
|
return IdentifyType(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::optional<VAddr> LoadModule(Kernel::Process& process, const FileSys::VfsFile& file,
|
static std::optional<VAddr> LoadModule(Kernel::Process& process, Core::System& system,
|
||||||
VAddr load_base, bool should_pass_arguments,
|
const FileSys::VfsFile& file, VAddr load_base,
|
||||||
bool load_into_process,
|
bool should_pass_arguments, bool load_into_process,
|
||||||
std::optional<FileSys::PatchManager> pm = {});
|
std::optional<FileSys::PatchManager> pm = {});
|
||||||
|
|
||||||
LoadResult Load(Kernel::Process& process) override;
|
LoadResult Load(Kernel::Process& process, Core::System& system) override;
|
||||||
|
|
||||||
ResultStatus ReadNSOModules(Modules& modules) override;
|
ResultStatus ReadNSOModules(Modules& modules) override;
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ FileType AppLoader_NSP::IdentifyType(const FileSys::VirtualFile& file) {
|
||||||
return FileType::Error;
|
return FileType::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
AppLoader_NSP::LoadResult AppLoader_NSP::Load(Kernel::Process& process) {
|
AppLoader_NSP::LoadResult AppLoader_NSP::Load(Kernel::Process& process, Core::System& system) {
|
||||||
if (is_loaded) {
|
if (is_loaded) {
|
||||||
return {ResultStatus::ErrorAlreadyLoaded, {}};
|
return {ResultStatus::ErrorAlreadyLoaded, {}};
|
||||||
}
|
}
|
||||||
|
@ -99,15 +99,14 @@ AppLoader_NSP::LoadResult AppLoader_NSP::Load(Kernel::Process& process) {
|
||||||
return {ResultStatus::ErrorNSPMissingProgramNCA, {}};
|
return {ResultStatus::ErrorNSPMissingProgramNCA, {}};
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto result = secondary_loader->Load(process);
|
const auto result = secondary_loader->Load(process, system);
|
||||||
if (result.first != ResultStatus::Success) {
|
if (result.first != ResultStatus::Success) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::VirtualFile update_raw;
|
FileSys::VirtualFile update_raw;
|
||||||
if (ReadUpdateRaw(update_raw) == ResultStatus::Success && update_raw != nullptr) {
|
if (ReadUpdateRaw(update_raw) == ResultStatus::Success && update_raw != nullptr) {
|
||||||
Core::System::GetInstance().GetFileSystemController().SetPackedUpdate(
|
system.GetFileSystemController().SetPackedUpdate(std::move(update_raw));
|
||||||
std::move(update_raw));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is_loaded = true;
|
is_loaded = true;
|
||||||
|
|
|
@ -9,6 +9,10 @@
|
||||||
#include "core/file_sys/vfs.h"
|
#include "core/file_sys/vfs.h"
|
||||||
#include "core/loader/loader.h"
|
#include "core/loader/loader.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
class NACP;
|
class NACP;
|
||||||
class NSP;
|
class NSP;
|
||||||
|
@ -35,7 +39,7 @@ public:
|
||||||
return IdentifyType(file);
|
return IdentifyType(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadResult Load(Kernel::Process& process) override;
|
LoadResult Load(Kernel::Process& process, Core::System& system) override;
|
||||||
|
|
||||||
ResultStatus ReadRomFS(FileSys::VirtualFile& file) override;
|
ResultStatus ReadRomFS(FileSys::VirtualFile& file) override;
|
||||||
u64 ReadRomFSIVFCOffset() const override;
|
u64 ReadRomFSIVFCOffset() const override;
|
||||||
|
|
|
@ -49,7 +49,7 @@ FileType AppLoader_XCI::IdentifyType(const FileSys::VirtualFile& file) {
|
||||||
return FileType::Error;
|
return FileType::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
AppLoader_XCI::LoadResult AppLoader_XCI::Load(Kernel::Process& process) {
|
AppLoader_XCI::LoadResult AppLoader_XCI::Load(Kernel::Process& process, Core::System& system) {
|
||||||
if (is_loaded) {
|
if (is_loaded) {
|
||||||
return {ResultStatus::ErrorAlreadyLoaded, {}};
|
return {ResultStatus::ErrorAlreadyLoaded, {}};
|
||||||
}
|
}
|
||||||
|
@ -66,15 +66,14 @@ AppLoader_XCI::LoadResult AppLoader_XCI::Load(Kernel::Process& process) {
|
||||||
return {ResultStatus::ErrorMissingProductionKeyFile, {}};
|
return {ResultStatus::ErrorMissingProductionKeyFile, {}};
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto result = nca_loader->Load(process);
|
const auto result = nca_loader->Load(process, system);
|
||||||
if (result.first != ResultStatus::Success) {
|
if (result.first != ResultStatus::Success) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::VirtualFile update_raw;
|
FileSys::VirtualFile update_raw;
|
||||||
if (ReadUpdateRaw(update_raw) == ResultStatus::Success && update_raw != nullptr) {
|
if (ReadUpdateRaw(update_raw) == ResultStatus::Success && update_raw != nullptr) {
|
||||||
Core::System::GetInstance().GetFileSystemController().SetPackedUpdate(
|
system.GetFileSystemController().SetPackedUpdate(std::move(update_raw));
|
||||||
std::move(update_raw));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is_loaded = true;
|
is_loaded = true;
|
||||||
|
|
|
@ -9,6 +9,10 @@
|
||||||
#include "core/file_sys/vfs.h"
|
#include "core/file_sys/vfs.h"
|
||||||
#include "core/loader/loader.h"
|
#include "core/loader/loader.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
class NACP;
|
class NACP;
|
||||||
class XCI;
|
class XCI;
|
||||||
|
@ -35,7 +39,7 @@ public:
|
||||||
return IdentifyType(file);
|
return IdentifyType(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadResult Load(Kernel::Process& process) override;
|
LoadResult Load(Kernel::Process& process, Core::System& system) override;
|
||||||
|
|
||||||
ResultStatus ReadRomFS(FileSys::VirtualFile& file) override;
|
ResultStatus ReadRomFS(FileSys::VirtualFile& file) override;
|
||||||
u64 ReadRomFSIVFCOffset() const override;
|
u64 ReadRomFSIVFCOffset() const override;
|
||||||
|
|
Loading…
Reference in a new issue