From 6d60acf0f1afcae873988da5218f2f1c7bc9d151 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Mon, 4 May 2015 00:01:16 -0300 Subject: Kernel: Introduce skeleton Process class to hold process data --- src/core/loader/ncch.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/core/loader/ncch.cpp') 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 #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 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(&ncch_header.program_id[0]); + Kernel::g_current_process = Kernel::Process::Create(process_name, program_id); + + // Copy data while converting endianess + std::array 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; -- cgit v1.2.3