mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-12 10:37:59 -05:00
Kernel: Store the program id in the Process class instead of the CodeSet class.
There may be many CodeSets per Process, so it's wasteful and overcomplicated to store the program id in each of them.
This commit is contained in:
@ -110,8 +110,6 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(
|
||||
return ResultStatus::Error;
|
||||
}
|
||||
|
||||
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";
|
||||
|
||||
@ -121,13 +119,15 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(
|
||||
}
|
||||
metadata.Print();
|
||||
|
||||
process = Kernel::Process::Create("main", metadata.GetTitleID());
|
||||
|
||||
// Load NSO modules
|
||||
VAddr next_load_addr{Memory::PROCESS_IMAGE_VADDR};
|
||||
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, metadata.GetTitleID());
|
||||
next_load_addr = AppLoader_NSO::LoadModule(path, load_addr);
|
||||
if (next_load_addr) {
|
||||
LOG_DEBUG(Loader, "loaded module %s @ 0x%" PRIx64, module, load_addr);
|
||||
} else {
|
||||
|
@ -300,7 +300,7 @@ SharedPtr<CodeSet> ElfReader::LoadInto(u32 vaddr) {
|
||||
std::vector<u8> program_image(total_image_size);
|
||||
size_t current_image_position = 0;
|
||||
|
||||
SharedPtr<CodeSet> codeset = CodeSet::Create("", 0);
|
||||
SharedPtr<CodeSet> codeset = CodeSet::Create("");
|
||||
|
||||
for (unsigned int i = 0; i < header->e_phnum; ++i) {
|
||||
Elf32_Phdr* p = &segments[i];
|
||||
@ -406,7 +406,7 @@ ResultStatus AppLoader_ELF::Load(Kernel::SharedPtr<Kernel::Process>& process) {
|
||||
SharedPtr<CodeSet> codeset = elf_reader.LoadInto(Memory::PROCESS_IMAGE_VADDR);
|
||||
codeset->name = filename;
|
||||
|
||||
process = Kernel::Process::Create("main");
|
||||
process = Kernel::Process::Create("main", 0);
|
||||
process->LoadModule(codeset, codeset->entrypoint);
|
||||
process->svc_access_mask.set();
|
||||
process->address_mappings = default_address_mappings;
|
||||
|
@ -83,7 +83,7 @@ bool AppLoader_NRO::LoadNro(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("");
|
||||
std::vector<u8> program_image;
|
||||
program_image.resize(PageAlignSize(nro_header.file_size));
|
||||
file.Seek(0, SEEK_SET);
|
||||
@ -125,7 +125,7 @@ ResultStatus AppLoader_NRO::Load(Kernel::SharedPtr<Kernel::Process>& process) {
|
||||
return ResultStatus::Error;
|
||||
}
|
||||
|
||||
process = Kernel::Process::Create("main");
|
||||
process = Kernel::Process::Create("main", 0);
|
||||
|
||||
// Load NRO
|
||||
static constexpr VAddr base_addr{Memory::PROCESS_IMAGE_VADDR};
|
||||
|
@ -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, u64 tid) {
|
||||
VAddr AppLoader_NSO::LoadModule(const std::string& path, VAddr load_base) {
|
||||
FileUtil::IOFile file(path, "rb");
|
||||
if (!file.IsOpen()) {
|
||||
return {};
|
||||
@ -109,7 +109,7 @@ VAddr AppLoader_NSO::LoadModule(const std::string& path, VAddr load_base, u64 ti
|
||||
}
|
||||
|
||||
// Build program image
|
||||
Kernel::SharedPtr<Kernel::CodeSet> codeset = Kernel::CodeSet::Create("", tid);
|
||||
Kernel::SharedPtr<Kernel::CodeSet> codeset = Kernel::CodeSet::Create("");
|
||||
std::vector<u8> program_image;
|
||||
for (int i = 0; i < nso_header.segments.size(); ++i) {
|
||||
std::vector<u8> data =
|
||||
@ -155,10 +155,10 @@ ResultStatus AppLoader_NSO::Load(Kernel::SharedPtr<Kernel::Process>& process) {
|
||||
return ResultStatus::Error;
|
||||
}
|
||||
|
||||
process = Kernel::Process::Create("main");
|
||||
process = Kernel::Process::Create("main", 0);
|
||||
|
||||
// Load module
|
||||
LoadModule(filepath, Memory::PROCESS_IMAGE_VADDR, 0);
|
||||
LoadModule(filepath, Memory::PROCESS_IMAGE_VADDR);
|
||||
LOG_DEBUG(Loader, "loaded module %s @ 0x%" PRIx64, filepath.c_str(),
|
||||
Memory::PROCESS_IMAGE_VADDR);
|
||||
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
return IdentifyType(file, filepath);
|
||||
}
|
||||
|
||||
static VAddr LoadModule(const std::string& path, VAddr load_base, u64 tid);
|
||||
static VAddr LoadModule(const std::string& path, VAddr load_base);
|
||||
|
||||
ResultStatus Load(Kernel::SharedPtr<Kernel::Process>& process) override;
|
||||
|
||||
|
Reference in New Issue
Block a user