diff options
| author | 2018-02-27 10:22:15 -0500 | |
|---|---|---|
| committer | 2018-03-01 19:03:53 -0500 | |
| commit | 827f8ca3c77ad0b7e667c64b5c983b3b3ffe8d7d (patch) | |
| tree | e557f60eddcd74f0ab380a81dd42749b3e46ef4e /src/core/loader | |
| parent | FS: Implement MountSaveData and some of the IFile interface. (diff) | |
| download | yuzu-827f8ca3c77ad0b7e667c64b5c983b3b3ffe8d7d.tar.gz yuzu-827f8ca3c77ad0b7e667c64b5c983b3b3ffe8d7d.tar.xz yuzu-827f8ca3c77ad0b7e667c64b5c983b3b3ffe8d7d.zip | |
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.
Diffstat (limited to 'src/core/loader')
| -rw-r--r-- | src/core/loader/deconstructed_rom_directory.cpp | 6 | ||||
| -rw-r--r-- | src/core/loader/elf.cpp | 4 | ||||
| -rw-r--r-- | src/core/loader/nro.cpp | 4 | ||||
| -rw-r--r-- | src/core/loader/nso.cpp | 8 | ||||
| -rw-r--r-- | src/core/loader/nso.h | 2 |
5 files changed, 12 insertions, 12 deletions
diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cpp index 864cf25cd..459d127c2 100644 --- a/src/core/loader/deconstructed_rom_directory.cpp +++ b/src/core/loader/deconstructed_rom_directory.cpp | |||
| @@ -110,8 +110,6 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load( | |||
| 110 | return ResultStatus::Error; | 110 | return ResultStatus::Error; |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | process = Kernel::Process::Create("main"); | ||
| 114 | |||
| 115 | const std::string directory = filepath.substr(0, filepath.find_last_of("/\\")) + DIR_SEP; | 113 | const std::string directory = filepath.substr(0, filepath.find_last_of("/\\")) + DIR_SEP; |
| 116 | const std::string npdm_path = directory + DIR_SEP + "main.npdm"; | 114 | const std::string npdm_path = directory + DIR_SEP + "main.npdm"; |
| 117 | 115 | ||
| @@ -121,13 +119,15 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load( | |||
| 121 | } | 119 | } |
| 122 | metadata.Print(); | 120 | metadata.Print(); |
| 123 | 121 | ||
| 122 | process = Kernel::Process::Create("main", metadata.GetTitleID()); | ||
| 123 | |||
| 124 | // Load NSO modules | 124 | // Load NSO modules |
| 125 | VAddr next_load_addr{Memory::PROCESS_IMAGE_VADDR}; | 125 | VAddr next_load_addr{Memory::PROCESS_IMAGE_VADDR}; |
| 126 | for (const auto& module : {"rtld", "main", "subsdk0", "subsdk1", "subsdk2", "subsdk3", | 126 | for (const auto& module : {"rtld", "main", "subsdk0", "subsdk1", "subsdk2", "subsdk3", |
| 127 | "subsdk4", "subsdk5", "subsdk6", "subsdk7", "sdk"}) { | 127 | "subsdk4", "subsdk5", "subsdk6", "subsdk7", "sdk"}) { |
| 128 | const std::string path = directory + DIR_SEP + module; | 128 | const std::string path = directory + DIR_SEP + module; |
| 129 | const VAddr load_addr = next_load_addr; | 129 | const VAddr load_addr = next_load_addr; |
| 130 | next_load_addr = AppLoader_NSO::LoadModule(path, load_addr, metadata.GetTitleID()); | 130 | next_load_addr = AppLoader_NSO::LoadModule(path, load_addr); |
| 131 | if (next_load_addr) { | 131 | if (next_load_addr) { |
| 132 | LOG_DEBUG(Loader, "loaded module %s @ 0x%" PRIx64, module, load_addr); | 132 | LOG_DEBUG(Loader, "loaded module %s @ 0x%" PRIx64, module, load_addr); |
| 133 | } else { | 133 | } else { |
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp index b87320656..cdd41f237 100644 --- a/src/core/loader/elf.cpp +++ b/src/core/loader/elf.cpp | |||
| @@ -300,7 +300,7 @@ SharedPtr<CodeSet> ElfReader::LoadInto(u32 vaddr) { | |||
| 300 | std::vector<u8> program_image(total_image_size); | 300 | std::vector<u8> program_image(total_image_size); |
| 301 | size_t current_image_position = 0; | 301 | size_t current_image_position = 0; |
| 302 | 302 | ||
| 303 | SharedPtr<CodeSet> codeset = CodeSet::Create("", 0); | 303 | SharedPtr<CodeSet> codeset = CodeSet::Create(""); |
| 304 | 304 | ||
| 305 | for (unsigned int i = 0; i < header->e_phnum; ++i) { | 305 | for (unsigned int i = 0; i < header->e_phnum; ++i) { |
| 306 | Elf32_Phdr* p = &segments[i]; | 306 | Elf32_Phdr* p = &segments[i]; |
| @@ -406,7 +406,7 @@ ResultStatus AppLoader_ELF::Load(Kernel::SharedPtr<Kernel::Process>& process) { | |||
| 406 | SharedPtr<CodeSet> codeset = elf_reader.LoadInto(Memory::PROCESS_IMAGE_VADDR); | 406 | SharedPtr<CodeSet> codeset = elf_reader.LoadInto(Memory::PROCESS_IMAGE_VADDR); |
| 407 | codeset->name = filename; | 407 | codeset->name = filename; |
| 408 | 408 | ||
| 409 | process = Kernel::Process::Create("main"); | 409 | process = Kernel::Process::Create("main", 0); |
| 410 | process->LoadModule(codeset, codeset->entrypoint); | 410 | process->LoadModule(codeset, codeset->entrypoint); |
| 411 | process->svc_access_mask.set(); | 411 | process->svc_access_mask.set(); |
| 412 | process->address_mappings = default_address_mappings; | 412 | process->address_mappings = default_address_mappings; |
diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp index 6f8a2f21e..c557b66dc 100644 --- a/src/core/loader/nro.cpp +++ b/src/core/loader/nro.cpp | |||
| @@ -83,7 +83,7 @@ bool AppLoader_NRO::LoadNro(const std::string& path, VAddr load_base) { | |||
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | // Build program image | 85 | // Build program image |
| 86 | Kernel::SharedPtr<Kernel::CodeSet> codeset = Kernel::CodeSet::Create("", 0); | 86 | Kernel::SharedPtr<Kernel::CodeSet> codeset = Kernel::CodeSet::Create(""); |
| 87 | std::vector<u8> program_image; | 87 | std::vector<u8> program_image; |
| 88 | program_image.resize(PageAlignSize(nro_header.file_size)); | 88 | program_image.resize(PageAlignSize(nro_header.file_size)); |
| 89 | file.Seek(0, SEEK_SET); | 89 | file.Seek(0, SEEK_SET); |
| @@ -125,7 +125,7 @@ ResultStatus AppLoader_NRO::Load(Kernel::SharedPtr<Kernel::Process>& process) { | |||
| 125 | return ResultStatus::Error; | 125 | return ResultStatus::Error; |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | process = Kernel::Process::Create("main"); | 128 | process = Kernel::Process::Create("main", 0); |
| 129 | 129 | ||
| 130 | // Load NRO | 130 | // Load NRO |
| 131 | static constexpr VAddr base_addr{Memory::PROCESS_IMAGE_VADDR}; | 131 | static constexpr VAddr base_addr{Memory::PROCESS_IMAGE_VADDR}; |
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index 7f8d24dd6..00b5d1d49 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp | |||
| @@ -92,7 +92,7 @@ static constexpr u32 PageAlignSize(u32 size) { | |||
| 92 | return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK; | 92 | return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK; |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | VAddr AppLoader_NSO::LoadModule(const std::string& path, VAddr load_base, u64 tid) { | 95 | VAddr AppLoader_NSO::LoadModule(const std::string& path, VAddr load_base) { |
| 96 | FileUtil::IOFile file(path, "rb"); | 96 | FileUtil::IOFile file(path, "rb"); |
| 97 | if (!file.IsOpen()) { | 97 | if (!file.IsOpen()) { |
| 98 | return {}; | 98 | return {}; |
| @@ -109,7 +109,7 @@ VAddr AppLoader_NSO::LoadModule(const std::string& path, VAddr load_base, u64 ti | |||
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | // Build program image | 111 | // Build program image |
| 112 | Kernel::SharedPtr<Kernel::CodeSet> codeset = Kernel::CodeSet::Create("", tid); | 112 | Kernel::SharedPtr<Kernel::CodeSet> codeset = Kernel::CodeSet::Create(""); |
| 113 | std::vector<u8> program_image; | 113 | std::vector<u8> program_image; |
| 114 | for (int i = 0; i < nso_header.segments.size(); ++i) { | 114 | for (int i = 0; i < nso_header.segments.size(); ++i) { |
| 115 | std::vector<u8> data = | 115 | std::vector<u8> data = |
| @@ -155,10 +155,10 @@ ResultStatus AppLoader_NSO::Load(Kernel::SharedPtr<Kernel::Process>& process) { | |||
| 155 | return ResultStatus::Error; | 155 | return ResultStatus::Error; |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | process = Kernel::Process::Create("main"); | 158 | process = Kernel::Process::Create("main", 0); |
| 159 | 159 | ||
| 160 | // Load module | 160 | // Load module |
| 161 | LoadModule(filepath, Memory::PROCESS_IMAGE_VADDR, 0); | 161 | LoadModule(filepath, Memory::PROCESS_IMAGE_VADDR); |
| 162 | LOG_DEBUG(Loader, "loaded module %s @ 0x%" PRIx64, filepath.c_str(), | 162 | LOG_DEBUG(Loader, "loaded module %s @ 0x%" PRIx64, filepath.c_str(), |
| 163 | Memory::PROCESS_IMAGE_VADDR); | 163 | Memory::PROCESS_IMAGE_VADDR); |
| 164 | 164 | ||
diff --git a/src/core/loader/nso.h b/src/core/loader/nso.h index 14eb1d87e..1ae30a824 100644 --- a/src/core/loader/nso.h +++ b/src/core/loader/nso.h | |||
| @@ -29,7 +29,7 @@ public: | |||
| 29 | return IdentifyType(file, filepath); | 29 | return IdentifyType(file, filepath); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | static VAddr LoadModule(const std::string& path, VAddr load_base, u64 tid); | 32 | static VAddr LoadModule(const std::string& path, VAddr load_base); |
| 33 | 33 | ||
| 34 | ResultStatus Load(Kernel::SharedPtr<Kernel::Process>& process) override; | 34 | ResultStatus Load(Kernel::SharedPtr<Kernel::Process>& process) override; |
| 35 | 35 | ||