diff options
| author | 2015-05-08 21:20:37 -0400 | |
|---|---|---|
| committer | 2015-05-08 21:20:37 -0400 | |
| commit | 917ac23dfcab37c65e11e3413e397863bd4bc000 (patch) | |
| tree | 956ca5d1a4aad3383c4a3bfc9103476abe3f1987 /src/core/loader/ncch.cpp | |
| parent | Merge pull request #728 from lioncash/vars (diff) | |
| parent | Kernel: Remove unused g_main_thread variable (diff) | |
| download | yuzu-917ac23dfcab37c65e11e3413e397863bd4bc000.tar.gz yuzu-917ac23dfcab37c65e11e3413e397863bd4bc000.tar.xz yuzu-917ac23dfcab37c65e11e3413e397863bd4bc000.zip | |
Merge pull request #731 from yuriks/app-info
Kernel: Process class and ExHeader caps parsing
Diffstat (limited to 'src/core/loader/ncch.cpp')
| -rw-r--r-- | src/core/loader/ncch.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp index 9bce2b79d..0e2db2fbb 100644 --- a/src/core/loader/ncch.cpp +++ b/src/core/loader/ncch.cpp | |||
| @@ -5,9 +5,12 @@ | |||
| 5 | #include <memory> | 5 | #include <memory> |
| 6 | 6 | ||
| 7 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 8 | #include "common/make_unique.h" | ||
| 9 | #include "common/string_util.h" | ||
| 10 | #include "common/swap.h" | ||
| 8 | 11 | ||
| 9 | #include "core/loader/ncch.h" | ||
| 10 | #include "core/hle/kernel/kernel.h" | 12 | #include "core/hle/kernel/kernel.h" |
| 13 | #include "core/loader/ncch.h" | ||
| 11 | #include "core/mem_map.h" | 14 | #include "core/mem_map.h" |
| 12 | 15 | ||
| 13 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 16 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| @@ -117,8 +120,21 @@ ResultStatus AppLoader_NCCH::LoadExec() const { | |||
| 117 | 120 | ||
| 118 | std::vector<u8> code; | 121 | std::vector<u8> code; |
| 119 | if (ResultStatus::Success == ReadCode(code)) { | 122 | if (ResultStatus::Success == ReadCode(code)) { |
| 123 | std::string process_name = Common::StringFromFixedZeroTerminatedBuffer( | ||
| 124 | (const char*)exheader_header.codeset_info.name, 8); | ||
| 125 | u64 program_id = *reinterpret_cast<u64_le const*>(&ncch_header.program_id[0]); | ||
| 126 | Kernel::g_current_process = Kernel::Process::Create(process_name, program_id); | ||
| 127 | |||
| 128 | // Copy data while converting endianess | ||
| 129 | std::array<u32, ARRAY_SIZE(exheader_header.arm11_kernel_caps.descriptors)> kernel_caps; | ||
| 130 | std::copy_n(exheader_header.arm11_kernel_caps.descriptors, kernel_caps.size(), begin(kernel_caps)); | ||
| 131 | Kernel::g_current_process->ParseKernelCaps(kernel_caps.data(), kernel_caps.size()); | ||
| 132 | |||
| 120 | Memory::WriteBlock(entry_point, &code[0], code.size()); | 133 | Memory::WriteBlock(entry_point, &code[0], code.size()); |
| 121 | Kernel::LoadExec(entry_point); | 134 | |
| 135 | s32 priority = exheader_header.arm11_system_local_caps.priority; | ||
| 136 | u32 stack_size = exheader_header.codeset_info.stack_size; | ||
| 137 | Kernel::g_current_process->Run(entry_point, priority, stack_size); | ||
| 122 | return ResultStatus::Success; | 138 | return ResultStatus::Success; |
| 123 | } | 139 | } |
| 124 | return ResultStatus::Error; | 140 | return ResultStatus::Error; |
| @@ -277,8 +293,4 @@ ResultStatus AppLoader_NCCH::ReadRomFS(std::vector<u8>& buffer) const { | |||
| 277 | return ResultStatus::ErrorNotUsed; | 293 | return ResultStatus::ErrorNotUsed; |
| 278 | } | 294 | } |
| 279 | 295 | ||
| 280 | u64 AppLoader_NCCH::GetProgramId() const { | ||
| 281 | return *reinterpret_cast<u64 const*>(&ncch_header.program_id[0]); | ||
| 282 | } | ||
| 283 | |||
| 284 | } // namespace Loader | 296 | } // namespace Loader |