summaryrefslogtreecommitdiffstats
path: root/src/core/loader
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/loader')
-rw-r--r--src/core/loader/deconstructed_rom_directory.cpp23
-rw-r--r--src/core/loader/deconstructed_rom_directory.h2
-rw-r--r--src/core/loader/nso.cpp6
-rw-r--r--src/core/loader/nso.h2
4 files changed, 24 insertions, 9 deletions
diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cpp
index 661803b5f..864cf25cd 100644
--- a/src/core/loader/deconstructed_rom_directory.cpp
+++ b/src/core/loader/deconstructed_rom_directory.cpp
@@ -53,6 +53,7 @@ AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileUti
FileType AppLoader_DeconstructedRomDirectory::IdentifyType(FileUtil::IOFile& file,
const std::string& filepath) {
bool is_main_found{};
+ bool is_npdm_found{};
bool is_rtld_found{};
bool is_sdk_found{};
@@ -67,6 +68,9 @@ FileType AppLoader_DeconstructedRomDirectory::IdentifyType(FileUtil::IOFile& fil
// Verify filename
if (Common::ToLower(virtual_name) == "main") {
is_main_found = true;
+ } else if (Common::ToLower(virtual_name) == "main.npdm") {
+ is_npdm_found = true;
+ return true;
} else if (Common::ToLower(virtual_name) == "rtld") {
is_rtld_found = true;
} else if (Common::ToLower(virtual_name) == "sdk") {
@@ -83,14 +87,14 @@ FileType AppLoader_DeconstructedRomDirectory::IdentifyType(FileUtil::IOFile& fil
}
// We are done if we've found and verified all required NSOs
- return !(is_main_found && is_rtld_found && is_sdk_found);
+ return !(is_main_found && is_npdm_found && is_rtld_found && is_sdk_found);
};
// Search the directory recursively, looking for the required modules
const std::string directory = filepath.substr(0, filepath.find_last_of("/\\")) + DIR_SEP;
FileUtil::ForeachDirectoryEntry(nullptr, directory, callback);
- if (is_main_found && is_rtld_found && is_sdk_found) {
+ if (is_main_found && is_npdm_found && is_rtld_found && is_sdk_found) {
return FileType::DeconstructedRomDirectory;
}
@@ -108,14 +112,22 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(
process = Kernel::Process::Create("main");
+ const std::string directory = filepath.substr(0, filepath.find_last_of("/\\")) + DIR_SEP;
+ const std::string npdm_path = directory + DIR_SEP + "main.npdm";
+
+ ResultStatus result = metadata.Load(npdm_path);
+ if (result != ResultStatus::Success) {
+ return result;
+ }
+ metadata.Print();
+
// Load NSO modules
VAddr next_load_addr{Memory::PROCESS_IMAGE_VADDR};
- const std::string directory = filepath.substr(0, filepath.find_last_of("/\\")) + DIR_SEP;
for (const auto& module : {"rtld", "main", "subsdk0", "subsdk1", "subsdk2", "subsdk3",
"subsdk4", "subsdk5", "subsdk6", "subsdk7", "sdk"}) {
const std::string path = directory + DIR_SEP + module;
const VAddr load_addr = next_load_addr;
- next_load_addr = AppLoader_NSO::LoadModule(path, load_addr);
+ next_load_addr = AppLoader_NSO::LoadModule(path, load_addr, metadata.GetTitleID());
if (next_load_addr) {
LOG_DEBUG(Loader, "loaded module %s @ 0x%" PRIx64, module, load_addr);
} else {
@@ -127,7 +139,8 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(
process->address_mappings = default_address_mappings;
process->resource_limit =
Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION);
- process->Run(Memory::PROCESS_IMAGE_VADDR, 48, Kernel::DEFAULT_STACK_SIZE);
+ process->Run(Memory::PROCESS_IMAGE_VADDR, metadata.GetMainThreadPriority(),
+ metadata.GetMainThreadStackSize());
// Find the RomFS by searching for a ".romfs" file in this directory
filepath_romfs = FindRomFS(directory);
diff --git a/src/core/loader/deconstructed_rom_directory.h b/src/core/loader/deconstructed_rom_directory.h
index 536a2dab7..23295d911 100644
--- a/src/core/loader/deconstructed_rom_directory.h
+++ b/src/core/loader/deconstructed_rom_directory.h
@@ -6,6 +6,7 @@
#include <string>
#include "common/common_types.h"
+#include "core/file_sys/program_metadata.h"
#include "core/hle/kernel/kernel.h"
#include "core/loader/loader.h"
@@ -41,6 +42,7 @@ public:
private:
std::string filepath_romfs;
std::string filepath;
+ FileSys::ProgramMetadata metadata;
};
} // namespace Loader
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp
index 407025da0..7f8d24dd6 100644
--- a/src/core/loader/nso.cpp
+++ b/src/core/loader/nso.cpp
@@ -92,7 +92,7 @@ static constexpr u32 PageAlignSize(u32 size) {
return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK;
}
-VAddr AppLoader_NSO::LoadModule(const std::string& path, VAddr load_base) {
+VAddr AppLoader_NSO::LoadModule(const std::string& path, VAddr load_base, u64 tid) {
FileUtil::IOFile file(path, "rb");
if (!file.IsOpen()) {
return {};
@@ -109,7 +109,7 @@ VAddr AppLoader_NSO::LoadModule(const std::string& path, VAddr load_base) {
}
// Build program image
- Kernel::SharedPtr<Kernel::CodeSet> codeset = Kernel::CodeSet::Create("", 0);
+ Kernel::SharedPtr<Kernel::CodeSet> codeset = Kernel::CodeSet::Create("", tid);
std::vector<u8> program_image;
for (int i = 0; i < nso_header.segments.size(); ++i) {
std::vector<u8> data =
@@ -158,7 +158,7 @@ ResultStatus AppLoader_NSO::Load(Kernel::SharedPtr<Kernel::Process>& process) {
process = Kernel::Process::Create("main");
// Load module
- LoadModule(filepath, Memory::PROCESS_IMAGE_VADDR);
+ LoadModule(filepath, Memory::PROCESS_IMAGE_VADDR, 0);
LOG_DEBUG(Loader, "loaded module %s @ 0x%" PRIx64, filepath.c_str(),
Memory::PROCESS_IMAGE_VADDR);
diff --git a/src/core/loader/nso.h b/src/core/loader/nso.h
index 1ae30a824..14eb1d87e 100644
--- a/src/core/loader/nso.h
+++ b/src/core/loader/nso.h
@@ -29,7 +29,7 @@ public:
return IdentifyType(file, filepath);
}
- static VAddr LoadModule(const std::string& path, VAddr load_base);
+ static VAddr LoadModule(const std::string& path, VAddr load_base, u64 tid);
ResultStatus Load(Kernel::SharedPtr<Kernel::Process>& process) override;