diff options
author | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2015-05-04 05:01:16 +0200 |
---|---|---|
committer | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2015-05-09 03:11:02 +0200 |
commit | 6d60acf0f1afcae873988da5218f2f1c7bc9d151 (patch) | |
tree | cec75198ab74759002dd1da78f6ac2af5e61949f /src/core/loader/ncch.cpp | |
parent | Common: Add StringFromFixedZeroTerminatedBuffer (diff) | |
download | yuzu-6d60acf0f1afcae873988da5218f2f1c7bc9d151.tar yuzu-6d60acf0f1afcae873988da5218f2f1c7bc9d151.tar.gz yuzu-6d60acf0f1afcae873988da5218f2f1c7bc9d151.tar.bz2 yuzu-6d60acf0f1afcae873988da5218f2f1c7bc9d151.tar.lz yuzu-6d60acf0f1afcae873988da5218f2f1c7bc9d151.tar.xz yuzu-6d60acf0f1afcae873988da5218f2f1c7bc9d151.tar.zst yuzu-6d60acf0f1afcae873988da5218f2f1c7bc9d151.zip |
Diffstat (limited to 'src/core/loader/ncch.cpp')
-rw-r--r-- | src/core/loader/ncch.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp index 9bce2b79d..531000137 100644 --- a/src/core/loader/ncch.cpp +++ b/src/core/loader/ncch.cpp @@ -5,9 +5,12 @@ #include <memory> #include "common/logging/log.h" +#include "common/make_unique.h" +#include "common/string_util.h" +#include "common/swap.h" -#include "core/loader/ncch.h" #include "core/hle/kernel/kernel.h" +#include "core/loader/ncch.h" #include "core/mem_map.h" //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -117,8 +120,21 @@ ResultStatus AppLoader_NCCH::LoadExec() const { std::vector<u8> code; if (ResultStatus::Success == ReadCode(code)) { + std::string process_name = Common::StringFromFixedZeroTerminatedBuffer( + (const char*)exheader_header.codeset_info.name, 8); + u64 program_id = *reinterpret_cast<u64_le const*>(&ncch_header.program_id[0]); + Kernel::g_current_process = Kernel::Process::Create(process_name, program_id); + + // Copy data while converting endianess + std::array<u32, ARRAY_SIZE(exheader_header.arm11_kernel_caps.descriptors)> kernel_caps; + std::copy_n(exheader_header.arm11_kernel_caps.descriptors, kernel_caps.size(), begin(kernel_caps)); + Kernel::g_current_process->ParseKernelCaps(kernel_caps.data(), kernel_caps.size()); + Memory::WriteBlock(entry_point, &code[0], code.size()); - Kernel::LoadExec(entry_point); + + s32 priority = exheader_header.arm11_system_local_caps.priority; + u32 stack_size = exheader_header.codeset_info.stack_size; + Kernel::g_current_process->Run(entry_point, priority, stack_size); return ResultStatus::Success; } return ResultStatus::Error; |