diff options
| author | 2018-12-04 12:26:12 -0500 | |
|---|---|---|
| committer | 2018-12-04 12:26:12 -0500 | |
| commit | 465f486160b59c72a85b0f75aca310647b38155c (patch) | |
| tree | 915750cb850ecc8f8f8ce01d5a55e91063daadcc | |
| parent | Merge pull request #1853 from lioncash/event (diff) | |
| parent | loader/nso: Remove dependency on the System class (diff) | |
| download | yuzu-465f486160b59c72a85b0f75aca310647b38155c.tar.gz yuzu-465f486160b59c72a85b0f75aca310647b38155c.tar.xz yuzu-465f486160b59c72a85b0f75aca310647b38155c.zip | |
Merge pull request #1845 from lioncash/nro
loader/{nro, nso}: Remove dependency on the System class
| -rw-r--r-- | src/core/loader/deconstructed_rom_directory.cpp | 3 | ||||
| -rw-r--r-- | src/core/loader/nro.cpp | 15 | ||||
| -rw-r--r-- | src/core/loader/nro.h | 8 | ||||
| -rw-r--r-- | src/core/loader/nso.cpp | 8 | ||||
| -rw-r--r-- | src/core/loader/nso.h | 8 |
5 files changed, 23 insertions, 19 deletions
diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cpp index 8518dddcb..ac04d72d7 100644 --- a/src/core/loader/deconstructed_rom_directory.cpp +++ b/src/core/loader/deconstructed_rom_directory.cpp | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | #include "common/common_funcs.h" | 7 | #include "common/common_funcs.h" |
| 8 | #include "common/file_util.h" | 8 | #include "common/file_util.h" |
| 9 | #include "common/logging/log.h" | 9 | #include "common/logging/log.h" |
| 10 | #include "core/core.h" | ||
| 11 | #include "core/file_sys/content_archive.h" | 10 | #include "core/file_sys/content_archive.h" |
| 12 | #include "core/file_sys/control_metadata.h" | 11 | #include "core/file_sys/control_metadata.h" |
| 13 | #include "core/file_sys/patch_manager.h" | 12 | #include "core/file_sys/patch_manager.h" |
| @@ -146,7 +145,7 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(Kernel::Process& process) | |||
| 146 | const VAddr load_addr = next_load_addr; | 145 | const VAddr load_addr = next_load_addr; |
| 147 | const bool should_pass_arguments = std::strcmp(module, "rtld") == 0; | 146 | const bool should_pass_arguments = std::strcmp(module, "rtld") == 0; |
| 148 | const auto tentative_next_load_addr = | 147 | const auto tentative_next_load_addr = |
| 149 | AppLoader_NSO::LoadModule(*module_file, load_addr, should_pass_arguments, pm); | 148 | AppLoader_NSO::LoadModule(process, *module_file, load_addr, should_pass_arguments, pm); |
| 150 | if (!tentative_next_load_addr) { | 149 | if (!tentative_next_load_addr) { |
| 151 | return ResultStatus::ErrorLoadingNSO; | 150 | return ResultStatus::ErrorLoadingNSO; |
| 152 | } | 151 | } |
diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp index fbbd6b0de..4fad0c0dd 100644 --- a/src/core/loader/nro.cpp +++ b/src/core/loader/nro.cpp | |||
| @@ -10,7 +10,6 @@ | |||
| 10 | #include "common/file_util.h" | 10 | #include "common/file_util.h" |
| 11 | #include "common/logging/log.h" | 11 | #include "common/logging/log.h" |
| 12 | #include "common/swap.h" | 12 | #include "common/swap.h" |
| 13 | #include "core/core.h" | ||
| 14 | #include "core/file_sys/control_metadata.h" | 13 | #include "core/file_sys/control_metadata.h" |
| 15 | #include "core/file_sys/romfs_factory.h" | 14 | #include "core/file_sys/romfs_factory.h" |
| 16 | #include "core/file_sys/vfs_offset.h" | 15 | #include "core/file_sys/vfs_offset.h" |
| @@ -129,9 +128,8 @@ static constexpr u32 PageAlignSize(u32 size) { | |||
| 129 | return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK; | 128 | return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK; |
| 130 | } | 129 | } |
| 131 | 130 | ||
| 132 | /*static*/ bool AppLoader_NRO::LoadNro(const std::vector<u8>& data, const std::string& name, | 131 | static bool LoadNroImpl(Kernel::Process& process, const std::vector<u8>& data, |
| 133 | VAddr load_base) { | 132 | const std::string& name, VAddr load_base) { |
| 134 | |||
| 135 | if (data.size() < sizeof(NroHeader)) { | 133 | if (data.size() < sizeof(NroHeader)) { |
| 136 | return {}; | 134 | return {}; |
| 137 | } | 135 | } |
| @@ -189,7 +187,7 @@ static constexpr u32 PageAlignSize(u32 size) { | |||
| 189 | 187 | ||
| 190 | // Load codeset for current process | 188 | // Load codeset for current process |
| 191 | codeset.memory = std::make_shared<std::vector<u8>>(std::move(program_image)); | 189 | codeset.memory = std::make_shared<std::vector<u8>>(std::move(program_image)); |
| 192 | Core::CurrentProcess()->LoadModule(std::move(codeset), load_base); | 190 | process.LoadModule(std::move(codeset), load_base); |
| 193 | 191 | ||
| 194 | // Register module with GDBStub | 192 | // Register module with GDBStub |
| 195 | GDBStub::RegisterModule(name, load_base, load_base); | 193 | GDBStub::RegisterModule(name, load_base, load_base); |
| @@ -197,8 +195,9 @@ static constexpr u32 PageAlignSize(u32 size) { | |||
| 197 | return true; | 195 | return true; |
| 198 | } | 196 | } |
| 199 | 197 | ||
| 200 | bool AppLoader_NRO::LoadNro(const FileSys::VfsFile& file, VAddr load_base) { | 198 | bool AppLoader_NRO::LoadNro(Kernel::Process& process, const FileSys::VfsFile& file, |
| 201 | return AppLoader_NRO::LoadNro(file.ReadAllBytes(), file.GetName(), load_base); | 199 | VAddr load_base) { |
| 200 | return LoadNroImpl(process, file.ReadAllBytes(), file.GetName(), load_base); | ||
| 202 | } | 201 | } |
| 203 | 202 | ||
| 204 | ResultStatus AppLoader_NRO::Load(Kernel::Process& process) { | 203 | ResultStatus AppLoader_NRO::Load(Kernel::Process& process) { |
| @@ -209,7 +208,7 @@ ResultStatus AppLoader_NRO::Load(Kernel::Process& process) { | |||
| 209 | // Load NRO | 208 | // Load NRO |
| 210 | const VAddr base_address = process.VMManager().GetCodeRegionBaseAddress(); | 209 | const VAddr base_address = process.VMManager().GetCodeRegionBaseAddress(); |
| 211 | 210 | ||
| 212 | if (!LoadNro(*file, base_address)) { | 211 | if (!LoadNro(process, *file, base_address)) { |
| 213 | return ResultStatus::ErrorLoadingNRO; | 212 | return ResultStatus::ErrorLoadingNRO; |
| 214 | } | 213 | } |
| 215 | 214 | ||
diff --git a/src/core/loader/nro.h b/src/core/loader/nro.h index 3e6959302..6deff3a51 100644 --- a/src/core/loader/nro.h +++ b/src/core/loader/nro.h | |||
| @@ -14,6 +14,10 @@ namespace FileSys { | |||
| 14 | class NACP; | 14 | class NACP; |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | namespace Kernel { | ||
| 18 | class Process; | ||
| 19 | } | ||
| 20 | |||
| 17 | namespace Loader { | 21 | namespace Loader { |
| 18 | 22 | ||
| 19 | /// Loads an NRO file | 23 | /// Loads an NRO file |
| @@ -41,10 +45,8 @@ public: | |||
| 41 | ResultStatus ReadTitle(std::string& title) override; | 45 | ResultStatus ReadTitle(std::string& title) override; |
| 42 | bool IsRomFSUpdatable() const override; | 46 | bool IsRomFSUpdatable() const override; |
| 43 | 47 | ||
| 44 | static bool LoadNro(const std::vector<u8>& data, const std::string& name, VAddr load_base); | ||
| 45 | |||
| 46 | private: | 48 | private: |
| 47 | bool LoadNro(const FileSys::VfsFile& file, VAddr load_base); | 49 | bool LoadNro(Kernel::Process& process, const FileSys::VfsFile& file, VAddr load_base); |
| 48 | 50 | ||
| 49 | std::vector<u8> icon_data; | 51 | std::vector<u8> icon_data; |
| 50 | std::unique_ptr<FileSys::NACP> nacp; | 52 | std::unique_ptr<FileSys::NACP> nacp; |
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index aaf006309..6ded0b707 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp | |||
| @@ -9,7 +9,6 @@ | |||
| 9 | #include "common/file_util.h" | 9 | #include "common/file_util.h" |
| 10 | #include "common/logging/log.h" | 10 | #include "common/logging/log.h" |
| 11 | #include "common/swap.h" | 11 | #include "common/swap.h" |
| 12 | #include "core/core.h" | ||
| 13 | #include "core/file_sys/patch_manager.h" | 12 | #include "core/file_sys/patch_manager.h" |
| 14 | #include "core/gdbstub/gdbstub.h" | 13 | #include "core/gdbstub/gdbstub.h" |
| 15 | #include "core/hle/kernel/process.h" | 14 | #include "core/hle/kernel/process.h" |
| @@ -93,7 +92,8 @@ static constexpr u32 PageAlignSize(u32 size) { | |||
| 93 | return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK; | 92 | return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK; |
| 94 | } | 93 | } |
| 95 | 94 | ||
| 96 | std::optional<VAddr> AppLoader_NSO::LoadModule(const FileSys::VfsFile& file, VAddr load_base, | 95 | std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process, |
| 96 | const FileSys::VfsFile& file, VAddr load_base, | ||
| 97 | bool should_pass_arguments, | 97 | bool should_pass_arguments, |
| 98 | std::optional<FileSys::PatchManager> pm) { | 98 | std::optional<FileSys::PatchManager> pm) { |
| 99 | if (file.GetSize() < sizeof(NsoHeader)) | 99 | if (file.GetSize() < sizeof(NsoHeader)) |
| @@ -166,7 +166,7 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(const FileSys::VfsFile& file, VAd | |||
| 166 | 166 | ||
| 167 | // Load codeset for current process | 167 | // Load codeset for current process |
| 168 | codeset.memory = std::make_shared<std::vector<u8>>(std::move(program_image)); | 168 | codeset.memory = std::make_shared<std::vector<u8>>(std::move(program_image)); |
| 169 | Core::CurrentProcess()->LoadModule(std::move(codeset), load_base); | 169 | process.LoadModule(std::move(codeset), load_base); |
| 170 | 170 | ||
| 171 | // Register module with GDBStub | 171 | // Register module with GDBStub |
| 172 | GDBStub::RegisterModule(file.GetName(), load_base, load_base); | 172 | GDBStub::RegisterModule(file.GetName(), load_base, load_base); |
| @@ -181,7 +181,7 @@ ResultStatus AppLoader_NSO::Load(Kernel::Process& process) { | |||
| 181 | 181 | ||
| 182 | // Load module | 182 | // Load module |
| 183 | const VAddr base_address = process.VMManager().GetCodeRegionBaseAddress(); | 183 | const VAddr base_address = process.VMManager().GetCodeRegionBaseAddress(); |
| 184 | if (!LoadModule(*file, base_address, true)) { | 184 | if (!LoadModule(process, *file, base_address, true)) { |
| 185 | return ResultStatus::ErrorLoadingNSO; | 185 | return ResultStatus::ErrorLoadingNSO; |
| 186 | } | 186 | } |
| 187 | LOG_DEBUG(Loader, "loaded module {} @ 0x{:X}", file->GetName(), base_address); | 187 | LOG_DEBUG(Loader, "loaded module {} @ 0x{:X}", file->GetName(), base_address); |
diff --git a/src/core/loader/nso.h b/src/core/loader/nso.h index 433306139..0c1defbb6 100644 --- a/src/core/loader/nso.h +++ b/src/core/loader/nso.h | |||
| @@ -10,6 +10,10 @@ | |||
| 10 | #include "core/loader/linker.h" | 10 | #include "core/loader/linker.h" |
| 11 | #include "core/loader/loader.h" | 11 | #include "core/loader/loader.h" |
| 12 | 12 | ||
| 13 | namespace Kernel { | ||
| 14 | class Process; | ||
| 15 | } | ||
| 16 | |||
| 13 | namespace Loader { | 17 | namespace Loader { |
| 14 | 18 | ||
| 15 | constexpr u64 NSO_ARGUMENT_DATA_ALLOCATION_SIZE = 0x9000; | 19 | constexpr u64 NSO_ARGUMENT_DATA_ALLOCATION_SIZE = 0x9000; |
| @@ -37,8 +41,8 @@ public: | |||
| 37 | return IdentifyType(file); | 41 | return IdentifyType(file); |
| 38 | } | 42 | } |
| 39 | 43 | ||
| 40 | static std::optional<VAddr> LoadModule(const FileSys::VfsFile& file, VAddr load_base, | 44 | static std::optional<VAddr> LoadModule(Kernel::Process& process, const FileSys::VfsFile& file, |
| 41 | bool should_pass_arguments, | 45 | VAddr load_base, bool should_pass_arguments, |
| 42 | std::optional<FileSys::PatchManager> pm = {}); | 46 | std::optional<FileSys::PatchManager> pm = {}); |
| 43 | 47 | ||
| 44 | ResultStatus Load(Kernel::Process& process) override; | 48 | ResultStatus Load(Kernel::Process& process) override; |